I've pasted the code from how to do this that is available at the msdn page. For further reference have a look at the link at the bottom. Change the returning string at GetConnectionString() or replace it all together with a simple string. It's up to you and the situation you are facing.
private static void OpenSqlConnection()
{
string connectionString = GetConnectionString();
using (SqlConnection connection = new SqlConnection())
{
connection.ConnectionString = connectionString;
connection.Open();
Console.WriteLine("State: {0}\nConnectionString: {1};", connection.State, connection.ConnectionString);
}
}
static private string GetConnectionString()
{
return "Data Source=YourDataSource;Initial Catalog=yourCatalog;Integrated Security=true;";
}
Source:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx[
^]
Regards