DBStorage.InitStorage Method
The InitStorage method initializes a DBStorage object. You must call this method immediately after object creation and before calling any other DBStorage object methods. Attempting to call any other DBStorage method prior to calling InitStorage results in an error.
Syntax
DBStorage.InitStorage(ConnectionString, Table, Key, ProgID, MarshalColumn, DateChanged)
Parameters
-
ConnectionString
-
A connection string for the data source, specified as a text string variant.
Note
For compatibility with sites built with Commerce 2.0, the Datasource parameter may also be a Datasource object retrieved through a previous call to the Content object’s AddDatasource method. However, new sites should not rely on this feature, as it will be discontinued in future releases of Commerce Server.
-
Table
-
The table within the data source in which to maintain the data.
-
Key
-
The column name that the DBStorage object uses as a key into the database table. This column should be marked to contain unique values.
-
ProgID
-
The object in which data passed to or retrieved by DBStorage methods will be stored. This parameter can be Commerce.Dictionary for storing Dictionary objects or Commerce.OrderForm for storing OrderForm objects. Methods (such as GetData) that return data from the database create an instance of the specified class with the requested data stored within it.
-
MarshalColumn
-
Optional. Text string which, if specified, indicates the name of a column in the database into which the CommitData or InsertData method will store all the data from the specified data object, serialized into an encoded binary format. (Objects in the stored item that have corresponding column names in the database are also stored in those columns in the database.) If this argument is specified, the database must contain a column by that name, or else an error will be produced. If this argument is not specified here, then no data from the object is serialized and saved in the database in binary format, and items in the object that do not have corresponding columns in the database are discarded. When using a Microsoft® SQL Server™ database, the maximum size of the data in this column is the same as the maximum size for the SQL Server text/image datatype (2,147,483,647 bytes).
-
DateChanged
-
Optional. The name of a key or attribute in the database into which to write the date when the data is changed. (If you do not specify a column name that exists in the database, the change date will be included in the marshalled data.)
Example
The following sample, from the Clocktower’s Basket.asp file, initializes the DBStorage object called mscsOrderFormStorage
as an OrderForm storage object:
Call mscsOrderFormStorage.InitStorage(MSCSSite.DefaultConnectionString, "Clocktower_basket", "shopper_id", "Commerce.OrderForm", "marshalled_order", "date_changed")
In this example:
-
υ
MSCSSite.DefaultConnectionString
returns a connection string representing the data source.
-
υ
"Clocktower_basket"
is the name of the table in the referenced data source.
-
υ
"shopper_id"
identifies the primary key into that table. This is the column name that the DBStorage object will use to key into the table to perform routine tasks such as data insertion and retrieval.
-
υ
"Commerce.OrderForm"
is the programmatic identifier of the object that you will use to pass data to and retrieve data from DBStorage methods, in this case an OrderForm object.
-
υ
"marshalled_order"
is the name of a column for this DBStorage object instance to use for marshaling data.
-
υ
"date_changed"
is the name of the column in the database that will contain the date of the most recent change.
Related Topics
© 1997-1998 Microsoft Corporation. All rights reserved.