<connectionStrings>
<clear/>
<add name="AdventureWorksString"
providerName="System.Data.SqlClient"
connectionString="Data Source=localhost;
Initial Catalog=AdventureWorks; Integrated Security=true"/>
</connectionStrings>
individualSettings=configurationManager.Connection Strings[0];
DbConnection MyConnection = null;
switch (individualSettings.ProviderName)
{
case "System.Data.SqlClient":
MyConnection = new SqlConnection(individualSettings.ConnectionString) ;
break;
case "System.Data.OracleClient":
MyConnection = new
OracleConnection(individualSettings.ConnectionStri ng);
break;
case "System.Data.OleDb":
MyConnection = new OleDbConnection(individualSettings.ConnectionStrin g);
break;
case "System.Data.Odbc":
MyConnection = new OdbcConnection(individualSettings.ConnectionString );
break;
}
what u need to do in app.cnfig use connection string and based on provider
name u can change the connection type u also need to initialize coomand and
other object u r using.
now when u change the connection string in app.config it generate the
connection, command object based on coonection string.
"Edwin Smith" wrote:
Hello:
I'm using VS2005 with an ODBC database.
I am trying to add a Dialog to an existing Database application to allow the
user to select the database. We have 2 different databases with the same
schema so this is a very desirable function.
I can configure 2 different connection strings in app,config but I can't
figure out how to allow the user to select one or the other.
This should be a simple task but I seem to be missing something. I am very
new to VS2005 so please forgive me for being naïve.
Thanks
Edwin