DBStorage.InitStorage

Ee799196.c++_on(en-US,CS.10).gifEe799196.vb_off(en-US,CS.10).gif

Use this method to initialize the DBStorage object. You must call this method immediately after object creation and before calling any other object methods. Attempting to call any other method prior to calling the InitStorage method results in an error.

Definition

Sub InitStorage(vtDataSourceOrDSN As Variant,Table As String,bstrKey As String,vtProgID As Variant,vtMarshal As Variant,vtChanged As Variant)

Parameters

vtDataSourceOrDSN

A Variant that contains a valid object reference to a DataSource object, or data source name (DSN).

Table

A String that contains the name of the table within the data source in which to maintain the data.

bstrKey

A String that contains the column name that the DBStorage object uses as a key into the database table. This column should be marked to contain unique values.

vtProgID

A Variant that contains the ProgID of 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.

vtMarshal

A Variant that contains the text string that, 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 an error will result. If this argument is not specified, 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 data type (2,147,483,647 bytes).

vtChanged

A Variant that contains 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 marshaled data.)

Return Values

None.

Error Values

This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

Example

' strDSN is the data source connection string; OrderFormStorage 
' is an uninitialized Commerce.DBStorage object; "Site_basket" 
' is the name of the table in the referenced data source; 
' "shopper_id" is the primary key in the "Site_basket" table; 
' "marshalled_order" is the name of the column for this DBStorage 
' object instance to use for marshaling data; "date_changed" 
' is the name of the database column that contains the date
' of the most recent change
' This sample initializes OrderFormStorage as an OrderForm storage object:

OrderFormStorage.InitStorage(strDSN, "Site_basket", "shopper_id", _
    "Commerce.OrderForm", "marshalled_order", "date_changed")

See Also

DBStorage Object


All rights reserved.