private void button3_Click(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter SAD = new SqlDataAdapter("DELETE FROM Table1 WHERE ID_='"+textBox4.Text.ToString() + "'", con);
SAD.SelectCommand.ExecuteNonQuery();
MessageBox.Show("DELETE ALREADY!");
string query = "SELECT * FROM Table1";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}
答案 0 :(得分:0)
我认为您想删除重复项,但只保留一个。 你可以试试这个吗?
DELETE FROM Table1
WHERE ID_ NOT IN
(
SELECT ID_
FROM Table1
)