如何同时删除几个表里面的记录呢?
我想从当前datagridview里面删除数据,操作成了。但是如果我想同步删除相关的几条记录,如何做呢?
代码如下:
string delete_No = this.dataGridView1.SelectedRows[0].Cells["编号"].Value.ToString(); string strConnect = Properties.Settings.Default.PopInfoConnectionString; SqlConnection conConnection = new SqlConnection(strConnect); conConnection.Open(); string cmd = "delete from [aaa] where id=" + delete_No + ""; SqlCommand com = new SqlCommand(cmd, conConnection); { com.ExecuteNonQuery(); this.dataGridView1.Rows.RemoveAt(this.dataGridView1.SelectedRows[0].Index); MessageBox.Show("记录已成功删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }