Code to Connect to the Expression Store
A connection to the Expression Store can be made either directly through the Connect method of an ExpressionStore object or indirectly through the Connect method of an ExpressionEval object. The determining factor will be which operations need to be performed. Use an ExpressionStore object if expressions are to be created or manipulated. If evaluating existing expressions, use an ExpressionEval object. When connecting through an ExpressionStore object, use the Disconnect method to release the connection to the Expression Store. The ExpressionEval object automatically releases the connection to the Expression Store upon termination.
Connecting Using an ExpressionStore Object
Connecting Using an ExpressionEval Object
Connecting Using an ExpressionStore Object
Retrieve the connection string to the Expression Store using a SiteConfigReadOnly object. Initialize the SiteConfigReadOnly object for the "Retail" site. This step should be performed in the Global.asa file and the resulting connection string cached in the Application collection or in a global dictionary for use in Active Server Pages (ASP) pages.
Dim sConn Dim oSiteConfigReadOnly Set oSiteConfigReadOnly = Server.CreateObject("Commerce.SiteConfigReadOnly") oSiteConfigReadOnly.Initialize "Retail" sConn = oSiteConfigReadOnly.Fields("Biz Data Service")_ .Value.Fields("s_BizDataStoreConnectionString").Value Set oSiteConfigReadOnly = Nothing
Create the ExpressionStore object and store the connection string to the Expression Store.
Dim oExpressionStore Set oExpressionStore = Server.CreateObject("Commerce.ExpressionStore") oExpressionStore.Connect sConn
Connecting Using an ExpressionEval Object
Connection through the use of an ExpressionEval object can made by passing a reference to an existing ExpressionStore object or by passing an explicit connection string, in which case a new ExpressionStore object will be created.
Create the ExpressionEval object. Note that the ProgID, ExpressionEvaluator, is different than the object name.
Dim oExpressionEval Set oExpressionEval = Server.CreateObject("Commerce.ExpressionEvaluator")
Connect to the Expression Store.
Connect using the previous ExpressionStore object, oExpressionStore.
oExpressionEval.Connect oExpressionStore
Connect using the previously obtained connection string, sConn.
oExpressionEval.Connect sConn