Hi folks,
I am using Visual Studio 2005 (C#) with SQL Server 2000. In my app.config file i have got a couple of connection strings to different SQL databases.
What I am wanting to do is to be able to create a SQL connection to a specific database using a specific connection string in the app.config file.
I have looked through the help files and there is nothing which sticks out.
I have founda method to get the connection string:
Code:
private DbConnection GetDatabaseConnection ( string name )
{
ConnectionStringSettings settings =
ConfigurationSettings.ConnectionStrings[name];
DbProviderFactory factory = DbProviderFactories.GetFactory
( settings.ProviderName ) ;
DbConnection conn = factory.CreateConnection ( ) ;
conn.ConnectionString = settings.ConnectionString ;
return conn ;
}
But how would I use this to create a SQl connection??
Any help would be great thanks!!