Hi you can use the following approach
String ConnString = string.Empty;
switch (DB)
{
case "ABC":
ConnString = "Data Source=MS-TOSHIBA;Initial Catalog=dalily system;Integrated Security=True";
break;
case "DEF":
ConnString = "Data Source=MS-TOSHIBA2;Initial Catalog=dalily system;Integrated Security=True";
break;
case "XYZ":
ConnString = "Data Source= "+DB+";Initial Catalog=dalily system;Integrated Security=True";
break;
default:
ConnString = "Data Source=MS-MYHOME;Initial Catalog=dalily system;Integrated Security=True";
break;
}
SqlConnection conn = new SqlConnection(ConnString);
Can you directly use hardcode connection string as it is done in Case 1 & 2 or you can create it at run time as mentioned in case XYZ
Hope it helps.... cheerz