Share via


IMSCSDBStorage_4_0::InitStorage Method

Dd451326.alert_caution(en-US,CS.90).gifImportant Note:

The DBStorage object is obsolete and is provided for migration scenarios only. To persist orders, use classes in the Microsoft.CommerceServer.Orders and Microsoft.CommerceServer.Runtime.Orders namespaces.

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.

HRESULT IMSCSDBStorage_4_0::InitStorage(
 VARIANT vtDataSourceOrDSN,
 BSTR Table,
 BSTR bstrKey,
 VARIANT vtProgID,
 VARIANT vtMarshal,
 VARIANT vtChanged
);
Sub InitStorage(
  vtDataSourceOrDSN As Variant,
  Table As String,
  bstrKey As String,
  vtProgID As Variant,
  vtMarshal As Variant,
  vtChanged As Variant
)

Parameters

  • vtDataSourceOrDSN
    [C++]

    [in] A VARIANT that references a valid IDispatch pointer on a DataSource object, or that references a data source name (DSN).

    [Visual Basic]

    A Variant that references a data source name (DSN).

  • Table
    [C++]

    [in] A BSTR that contains the name of the table within the data source in which to maintain the data.

    [Visual Basic]

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

  • bstrKey
    [C++]

    [in] A BSTR that contains the column name that the DBStorage object uses as a key to the database table. Mark this column to contain unique values.

    [Visual Basic]

    A String that contains the column name that the DBStorage object uses as a key to the database table. Mark this column to contain unique values.

  • vtProgID
    [C++]

    [in] 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.

    [Visual Basic]

    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
    [C++]

    [in] 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 you specify this argument, the database must contain a column by that name, or an error will result. If you do not specify this argument, 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).

    [Visual Basic]

    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 you specify this argument, the database must contain a column by that name, or an error will result. If you do not specify this argument, 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
    [C++]

    [in] 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.

    [Visual Basic]

    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

[C++]

This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic]

None.

Error Values

[C++]

This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT 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, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic]

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.

See Also

Other Resources

DBStorage Object