IExpressionStore::Connect Method [C++]

Use this method to store the connection string to an expression store.

Definition

[C++]

HRESULT IExpressionStore::Connect(BSTRstrConnStr);

[Visual Basic]

Sub Connect(strConnStr As String)

Parameters

  • strConnStr[C++]
    [in] A BSTR that contains the database connection information for the expression store.
  • strConnStr[Visual Basic]
    [in] A String that contains the database connection information for the expression store.

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 either standard or custom COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to either standard or custom COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM errors that this method can return.

Constant Value Description
E_EXPR_BADCONNECTION

[C++] 0x8110001F

[Visual Basic] &H8110001F

Invalid connection
E_EXPR_BADEXPRSTORE

[C++] 0x8110001E

[Visual Basic] &H8110001E

Specified database does not contain a valid expression store
E_EXPR_NOCONNECTIONSTRING

[C++] 0x8110000D

[Visual Basic] &H8110000D

No connection string specified
E_EXPR_STOREPERMISSIONS

[C++] 0x8110000F

[Visual Basic] &H8110000F

Insufficient access permissions on the expression store database

[C++] 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] Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

The ExpressionStore object does not maintain a persistent ADO connection. This method stores the connection string after validating that the connection string points to an actual expression store. The Disconnect method sets the connection string to an empty string.

Each method of the ExpressionStore object creates a connection when needed, and when done with it, closes the connection. This relies on ADO connection pooling and provides higher availability.

The connection string for the expression store may be obtained through the SiteConfigReadOnly object or through the Commerce Server Manager console from the s_BizDataStoreConnectionString property under the key "Commerce Server Manager\Global Resources\Profiles".

The Connect method must be successfully executed before calling any other method of an externally created ExpressionStore object.

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

Example [Visual Basic]

[Visual Basic]

' Connect using an explicit connection string .
' oExpressionStore is a valid ExpressionStore object

oExpressionStore.Connect "Provider=SQLOLEDB;Data Source=server;" _
& "Initial Catalog=Retail_commerce;Integrated Security='SSPI'"

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

sConn = oSCRO.Fields("Biz Data Service") _
.Value.Fields("s_BizDataStoreConnectionString").Value 
oExpressionStore.Connect sConn

See Also

[C++]ExpressionStore Object

[C++]IExpressionStore::Disconnect

[C++]SiteConfigReadOnly Object

[Visual Basic]ExpressionStore Object

[Visual Basic]ExpressionStore.Disconnect

[Visual Basic]SiteConfigReadOnly Object

Copyright © 2005 Microsoft Corporation.
All rights reserved.