Share via


IGenID::Initialize Method [C++]

Use this method to connect the GenID object to the database that stores the table of counters.

Definition

[C++]

HRESULT IGenID::Initialize(BSTRbstrDBConnectionString,
  longcBlockSizeHint);

[Visual Basic]

Sub Initialize(bstrDBConnectionString As String,
  Optional cBlockSizeHint As Long)

Parameters

  • bstrDBConnectionString[C++]
    [in] A BSTR that contains the connection information to the database.
  • bstrDBConnectionString[Visual Basic]
    A String that contains the connection information to the database.
  • cBlockSizeHint[C++]
    [in, optional, defaultvalue (1)] Not implemented, leave blank.
  • cBlockSizeHint[Visual Basic]
    Not implemented, leave blank.

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.

Remarks

This method must be called before calling the GetCounterValue and InitializeCounter methods.

The connection string may be obtained through the SiteConfigReadOnly object or through the Commerce Server Manager console from the connstr_db_Transactions property under Commerce Server Manager\Commerce Sites\<site name>\Site Resources\Transactions.

[Visual Basic]

Example

' oGenID``is a Commerce GenID object

' Connect using an explicit connection string.
oGenID.Initialize "Provider=SQLOLEDB;Data Source=server;" _
 & "Integrated Security='SSPI';Initial Catalog=Retail_commerce"

' Connect using a string retrieved from the SiteConfigReadOnly object.
' sConn is a String, oSCRO is an initialized SiteConfigReadOnly object

sConn = oSCRO.Fields("Transactions").Value.Fields("connstr_db_Transactions").Value
oGenID.Initialize sConn

See Also

[C++]GenID Object

[Visual Basic]GenID Object

Copyright © 2005 Microsoft Corporation.
All rights reserved.