Share via


DBStorage.InitStorage Method (PIA)

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

[Visual Basic .NET]

Imports Microsoft.CommerceServer.Interop.Orders
…
Public Sub InitStorage(vtDataSourceOrDSN As Object,
 Table As String,
 bstrKey As String,
 vtProgID As Object,
 vtMarshal As Object,
 vtChanged As Object)

[C#]

using Microsoft.CommerceServer.Interop.Orders;
…
public void InitStorage(objectvtDataSourceOrDSN,
 stringTable,
 stringbstrKey,
 objectvtProgID,
 objectvtMarshal,
 objectvtChanged);

Parameters

[Visual Basic .NET]

  • vtDataSourceOrDSN
    An Object 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
    An Object 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
    An Object 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
    An Object 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.)

[C#]

  • vtDataSourceOrDSN
    An object which references a valid DataSource object, or which references a 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
    An object that contains the ProgID of the object in which data passed to or retrieved by DBStorage methods will be stored. This parameter can be Microsoft.CommerceServer.Interop.Dictionary for storing Dictionary objects or Microsoft.CommerceServer.Interop.Orders.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
    An object 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
    An object 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.)

Exceptions

This method may throw one of many mapped exceptions or an exception of type COMException. See Standard COM Errors for additional details.

[Visual Basic .NET]

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")

Requirements

Namespace: Microsoft.CommerceServer.Interop.Orders

Platforms: Windows 2000, Windows Server 2003

Assembly: commercelib (in commercelib.dll)

See Also

DBStorage Class

Copyright © 2005 Microsoft Corporation.
All rights reserved.