I am planning to replace the factory created connection string which is from web.config with a function generated connection string. I am confused where to make this change?
Connection String in Web config as below:
<connectionStrings>
<add name="ConnectionStringToDB" connectionString="Data Source=GTD,2431;Network Library=DBMSSOCN;Initial Catalog=WorkflowExecutionDB;User ID=Dev_FID;Password=****" providerName="System.Data.SqlClient" />
</connectionStrings>
Currently following code will call this above connection string:
DatabaseProviderFactory factory; /* enterprise data library*/
Database ConnectionStringToDB; /* database schema*/
factory = new DatabaseProviderFactory();
// Create a Database object from the factory using the connection string name.
ConnectionStringToDB = factory.Create("ConnectionStringToDB");
DbCommand dbCmd = ConnectionStringToDB.GetStoredProcCommand("SP_Name");
Suppose i need to change the connection string which is coming from web-config to function method result as like below, where i need to put the GetConnectionString() in the code? :
public static string GetConnectionString()
{
return "Data Source=GTD,2431;Network Library=DBMSSOCN;Initial Catalog=WorkflowExecutionDB;User ID=Dev_FID;Password=****" providerName="System.Data.SqlClient"
}
Following might be wrong:
ConnectionStringToDB = factory.Create(GetConnectionString());
What the is the right way?