private void button1_Click(object sender, EventArgs e) { string sqlcmd = ""; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[0].Value != null) { sqlcmd += "delete from T_danhao where id = " + dataSet1.Tables[0].Rows[i][0].ToString() + ";"; //MessageBox.Show(sqlcmd); } } if (sqlcmd != "") { try { Cmd = new MySqlCommand(sqlcmd, Conn); Cmd.ExecuteNonQuery(); Fresh_table(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } }
时间: 2024-10-13 18:37:19