For one of my application, I required to get list of all the stores stored in StoreObject table in Profiles database. Here in this blog I will explain detail steps to connect the profile database
To connect to database, connection string will be retrieved using the CommerceResourceCollection object as
CommerceResourceCollection rescol = new CommerceResourceCollection (Commercecontext.Current.SiteName);
Here, Commerce Server .NET Application Framework creates the CommerceContext objects as a part of the processing for every page in commerce site.
Commercecontext.Current.SiteName returns the current site name. Available in namespace "Microsoft.CommerceServer.Runtime"
CommerceResourceCollection: This class represents the collection of the resources for the provided site. This class is available in Microsoft.CommerceServer.Runtime.Configuration namespace.
There are two types of resources
-
Global Resources : These resources are shared across commerce server sites
-
Site Resources: These resources are not shared across the sites.
Get the connection string to the profile data store as follows
String connStr = rescol ["Biz Data Service"] ["s_BizDataStoreConnectionString"].ToString( ) ;
Here, "Biz Data Service": - The name of resource to be retrieve
"s_BizDataStoreConnectionString": - The name of property whose value is retrieved
You can see those connection string values from Commerce Server Manager Tool.
Commerce Server Manager >> Global Resources >> Profiles
Once we get the connection string we can connect to the Profile Database and get the data from any table.

Sr KarthigaPosted Apr 3, 2016, 12:05 AM
good one
Sr KarthigaPosted Apr 3, 2016, 12:04 AM
nice explanation