Retrieving Data

In general, the Commerce Server Business Desk modules that ship with Microsoft Commerce Server 2000 make use of Active Data Objects (ADO) within ASP code to access a database and retrieve the relevant information in the form of an ADO Recordset object. Business Desk provides some global variables and utility functions for creating ADO Connection and Command objects that most of the Business Desk modules shipped with Commerce Server 2000 use. These variables and functions are defined in the Business Desk include file DBUtil.asp.

The DBUtil.asp include file includes the following line to define global ADO Connection and Command objects for use on Business Desk module ASP pages:

Dim g_oConn, g_oCmd

The DBUtil.asp include file defines the routine oGetADOConnection. This routine takes a connection string as its only parameter. It returns a reference to an ADO Connection object that has been initialized with connection and command timeouts of 15 and 30 seconds, respectively, and that has been opened using the passed connection string.

The DBUtil.asp include file also defines the routine oGetADOCommand. This routine takes a Connection object and a command type as parameters. It returns a reference to an ADO Command object that has been initialized to use the passed connection and command type. The passed command type is typically AD_CMD_TEXT, which is also defined in this file.

When these two routines are combined with the creation and opening of an ADO Recordset object, the result is a Recordset object containing the results from the query, ready to be converted into an XML data-island. For more information about converting a Recordset object into and XML data-island, see Getting Data to the Client. The strings sYourConnectionString and sYourSqlQuery, used in the following script, must have been defined elsewhere.

Set g_oConn = oGetADOConnection(sYourConnectionString)
Set g_oCmd = oGetADOCommand(g_oConn, AD_CMD_TEXT)

Dim rsRecSet
g_oCmd.CommandText = sYourSqlQuery
Set rsRecSet = Server.CreateObject("ADODB.Recordset")
rsRecSet.Open g_oCmd, , AD_OPEN_KEYSET, AD_LOCK_PESSIMISTIC


All rights reserved.