Previous in Contents Next in Contents

Content.AddDatasource Method

Note  The Content object is included in Commerce Server 3.0 only for backward compatibility with sites created in Commerce Server 2.0. New sites should be constructed using ADOs. Connection strings (DSNs) should be stored in the ConnectionStringMap (part of the site dictionary) and queries should be stored in the QueryMap Dictionary object.

The AddDatasource method associates a configured file or system DSN with a string alias.

Syntax

Content.AddDatasource(Alias, ConnectionString)

Parameters

Alias
A string that identifies the name by which you will reference the DSN in your site.
ConnectionString
A database connection string that contains connection and login information. Usually the database connection string is defined in the Dsn_include.asp file, which is included at the start of Global.asa.

Remarks

If you use more than one DSN in a site, you should specify one of them as the default DSN for the site. To do this, set the Application object's MSCSDefaultDatasource variable to reference the string variable name that you have associated with a DSN that you have added to the Content object query collection.

Example

The following example, from the Clocktower sample site, creates a Content object, adds a DSN variable to the object, and makes that DSN the default DSN for the site:

REM Create a Content object for access to the database
Set  MSCSContent = Server.CreateObject("Commerce.Content")
Call MSCSContent.AddDatasource("Clocktower", MSCSDSN)
Set  MSCSDataSource = MSCSContent.Datasource("Clocktower") 

' Later, in Application_OnStart
Application("MSCSDefaultDatasource") = "Clocktower"

Related Topics


© 1997-2000 Microsoft Corporation. All rights reserved.