Delete datagridview cell click event it says the information was deleted but after clicking the pop-out message the information was still there even if I deleted that certain information. Please help
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
string maincon = ConfigurationManager.ConnectionStrings["dbcs"].ConnectionString;
SqlConnection sqlcon = new SqlConnection(maincon);
int rfidno = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["rfidno"].FormattedValue.ToString());
try
{
SqlDataAdapter da = new SqlDataAdapter();
sqlcon.Open();
da.DeleteCommand = new SqlCommand("delete tbl_registerStudent where rfidno = '" + rfidno + "'", sqlcon);
da.DeleteCommand.ExecuteNonQuery();
MessageBox.Show("" + rfidno);
MessageBox.Show("Delete Successfull");
sqlcon.Close();
bindGrid();
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
This is the code of the bindGrid
public void bindGrid()
{
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-EB4EK81\SQLEXPRESS;Initial Catalog=TACLC;Integrated Security=True");
SqlCommand cmd = new SqlCommand("Select * from tbl_registerStudent", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
```