Studio 2010 C# application accessing LUW DBs. I am receiving an error when building my DB Conncetion settings in the code behind file rather than using the web.config. We have a third party product where passwords are stored and retrieved.
The old web.config file method currently establishs DB connection as follows:
In the web.config file:
<add name="myDBConnect" connectionString="Database=mydbname;User
ID=myuserid;Password=abcxyz" providerName="IBM.Data.DB2"/>
In the code behind file the following is executed to open the DB connection:
ConnectionStringSettings settings = WebConfigurationManager.ConnectionStrings["myDBConnect"];
ConnectionString = settings.ConnectionString;
ConnectionStringSettingsCollection settings = ConfigurationManager.ConnectionStrings;
if ((settings != null))
{
foreach (ConnectionStringSettings cs in settings)
{
returnValue = cs.ProviderName;
}
}
The above logic works fine - but I am now trying to dynamically build the connection string after retrieving the appropriate password from our third party product as follows:
(Note: connPW is the password retrieved from thrid party product)
ConnectionStringSettings settings = "Database=" + mydbname + ";User ID=" + myuserid + ";Password=" + connPW + " providerName=IBM.Data.DB2";
This line of code receives the following error: "Cannot implicitly convert type 'string' to 'System.Configuration.ConnctionStringSettings'
Can someone please suggest how I can get past this error when defining settings. Thanks
ConnectionStringSettings? Doesn't the connection string itself suffice?