the user will fill the (connection name, machine name or IP, database name, login ID, login password)
Add this code to the button event handler:
string connectionStringName = txtNewConn.Text;string connectionString = "Password=" + txtPassword.Text + ";Persist Security Info=True;User ID=" + txtUserLogin.Text + ";Initial Catalog=" + txtDBName.Text + ";Data Source=" + txtIP.Text;
ConnectionStringSettings Settings = new ConnectionStringSettings(connectionStringName, connectionString);
Settings.ProviderName = "System.Data.SqlClient";
var cfg = WebConfigurationManager.OpenWebConfiguration(@"/");
cfg.ConnectionStrings.ConnectionStrings.Add(Settings);
cfg.Save();

Kirtan PatelRank #292 · 8.6K reputationPosted Dec 27, 2009, 10:27 PM EST
Roshdy Abuzeid19 reputationPosted Dec 29, 2009, 5:14 AM EST
But it was closed and I was submitted the solution