private void btnDelete_Click(object sender, EventArgs e)
{
//dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
OleDbConnection con = new OleDbConnection(constr);
con.Open();
OleDbCommand cmd = new OleDbCommand("DELETE FROM tb1 WHERE name='@Name'", con);
cmd.Parameters.AddWithValue("@Name", txtproject_name.Text);
cmd.ExecuteNonQuery();
Bind();
MessageBox.Show("deleted......");
con.Close();
}
This is my code for deleting the data from a database on a button click...but it is not deleting anything..can anyone help me with the code
WHEREclause correct? I.e., are there any rows in the table that matchtxtproject_name.Text?DELETE FROM tb1 WHERE name=@Namefor your SQL. In other words, remove the single quotes - I believeAddWithValuewill put them in for you.