I think its bad idea to create a connection string at installation because if the string is not working then what?
its better if you use config file and create connection string from that config file.
for doing that you need to add a config file in your project. by default it is app.config.
now add <appsetting>tag inside the config file and add<key name="" and="" value="">
like...
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="Server" value=""/>
<add key="Database" value=""/>
<add key="ConnectionTimeout" value=""/>
<add key="UserID" value=""/>
<add key="Password" value=""/>
</appSettings>
</configuration>
add refrence of system.configuration dll.
To retrieve data of this config file use
ConfigurationManager.AppSettings[key]
now make connection string as
string ServerName = ConfigurationManager.AppSettings["Server"].ToString();
string Database = ConfigurationManager.AppSettings["Database"].ToString();
string ConnectionTimeout = ConfigurationManager.AppSettings["ConnectionTimeout"].ToString();
string UserID = ConfigurationManager.AppSettings["UserID"].ToString();
string Password = ConfigurationManager.Apps["Password"].ToString();
ConnectionString = "Data Source=" + ServerName + ";" +
"Initial Catalog=" + DataBaseName + ";" +
"Persist Security Info=True;" +
"User ID=" + UserID + ";" +
"Password=" + Password + ";" +
"Pooling=true;" +
"Connection Timeout=" + ConnectionTimeout;
now i think you got idea about i mean to say.
Whenever you wanted to change the connection string setting open that config file and change the value accordingly and the setting will applied.