for (int i=0; i < this.listBox1.SelectedItems.Count; i++)
{
SqlConnection con = new SqlConnection("server=INFO-PROJECT4\\SQLEXPRESS;database=nss;integrated security=true");
con.Open();
SqlCommand cmd = new SqlCommand("insert into sss(city) values(@city)",con);
cmd.Parameters.AddWithValue("@city", listBox1.SelectedItems[i].ToString());
cmd.ExecuteNonQuery();
MessageBox.Show("success");
con.Close();
}
No comments:
Post a Comment