1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| [ string[] tab ={ "@ip1", "@ip2" };//tablo contenant les # @ip des serveurs distants
string[] tabbd ={ "test1", "test2" };
for(int i=0;i<2;i++)
{
String connectionString = "Server = "+tab[i]+";User ID =sa; Password =; Integrated Security=SSPI";
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
string sql = "drop database "+tabbd[i]+"";
SqlCommand cmd = new SqlCommand(sql, conn);
try
{
cmd.ExecuteNonQuery();
}
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message.ToString());
}
conn.Close();] |
Partager