<connectionStri ngs>
<clear/>
<add name="Adventure WorksString"
providerName="S ystem.Data.SqlC lient"
connectionStrin g="Data Source=localhos t;
Initial Catalog=Adventu reWorks; Integrated Security=true"/>
</connectionStrin gs>
individualSetti ngs=configurati onManager.Conne ctionStrings[0];
DbConnection MyConnection = null;
switch (individualSett ings.ProviderNa me)
{
case "System.Data.Sq lClient":
MyConnection = new SqlConnection(i ndividualSettin gs.ConnectionSt ring);
break;
case "System.Data.Or acleClient":
MyConnection = new
OracleConnectio n(individualSet tings.Connectio nString);
break;
case "System.Data.Ol eDb":
MyConnection = new OleDbConnection (individualSett ings.Connection String);
break;
case "System.Data.Od bc":
MyConnection = new OdbcConnection( individualSetti ngs.ConnectionS tring);
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