COM+ Special, Introducing the In Memory Database
By: Jeroen Ritmeijer - www.xs4all.nl/~jarit/sns
(05/24/1999)
Introduction
One of the most exciting new features in Win2K for developers is the introduction of COM+. COM+ is a combination of the current version of COM as we all know and love it with some added extras, MTS including a load balancer, the In Memory DataBase and Queued Components using the MSMQ as an asynchronous transport for COM method invocations.
In this first article we will focus on setting up and accessing the IMDB from Active Server Pages.
Initially I planned to base this demonstration on a simple MS-Access database, however I did not get the IMDB to work with an Access .mdb file. So I had to resort to the Northwind database that is installed by default with MS-SQL Server 7.
Because of a bug in the IMDB we have to make some adjustments to the orders table, which I intend to use for this demonstration.
The current version of the IMDB locks up when more than 2 records contain a
Run the following SQL command to remove all
Although the full version of Windows 2000 is still many months away, it never hurts to look ahead and see what the future will bring us.
The Database
| UPDATE orders SET shippeddate = '5/6/1999' WHERE shippeddate IS NULL |
Configuring the IMDB is easy, you just need to know a few tricks to get things running.
|
Security settings Before you can access the IMDB from ASP you have to add the IWAM_machinename account to the 'IMDB Trusted User' role in the 'System Application' package.
|
![]() |
As the name implies the IMDB runs completely in memory. In order to fit an entire table into RAM we need to reserve memory for the IMDB:
Just like in traditional databases you need to create a container that holds all the tables you want to access.

To make sure the IMDB is up to date restart the IMDB service. This can be done by right clicking on 'My Computer' in the 'Component Services' MMC or by stopping the IMDB service by hand (net stop imdbserver).
Just like with other databases you use ADO to access the IMDB. One of the few differences is that the first release of the IMDB does not support SQL. This is not a huge problem, as the following piece of code will show.
|
<% set Conn = server.createobject("adodb.connection") set rs = server.createobject("adodb.recordset") Conn.Open "Provider=MSIMDB;Data Source=imdb_northwind" rs.cachesize = 100 rs.open "orders", Conn while not rs.eof response.write rs("orderid") & " - " & rs("ShipName") & "<BR>" rs.movenext wend rs.close Conn.close set rs = nothing set Conn = nothing %> |
The example above displays 830 records. What if we only want to display a subset of the entire table? Since we can't use SQL to narrow down the results we have to find another way.
Fortunately ADO exposes quite a number of methods and properties to filter, seek or order data.
The following example will display all records with an orderid between 10340 and 10350 and sort the results descending by ShipName.
|
<% set Conn = server.createobject("adodb.connection") set rs = server.createobject("adodb.recordset") Conn.Open "Provider=MSIMDB;Data Source=imdb_northwind" rs.cursorlocation = 3 '** adUseClient for .filter to work rs.cachesize = 100 rs.open "orders", Conn rs.filter = "orderid > 10340 and orderid < 10350" rs.sort = "shipname DESC" while not rs.eof response.write rs("orderid") & "-" & rs("ShipName") & "<BR>" rs.movenext wend rs.close Conn.close set rs = nothing set Conn = nothing %> |
In the example above I have also added the sort property. It's very important to set this property AFTER applying the filter. If you don't do this all records will be sorted, this is a waste of time since you are only interested in the filtered records.
That's it. Next issue we will discuss writing data to the IMDB and run some benchmarks.
There are still some issues with the IMDB and other COM+ service that I have not yet figured out since there is not a lot of documentation out there. Please contact me if you have information on one of the following:
About the author
Jeroen Ritmeijer is a Senior Software Engineer for Codim electronic media,
one of the larger multimedia companies in The Netherlands. He can be
reached at jarit@xs4all.nl.