Hey guys,
I have written a code that could delete selected row in data grid view. I gives lots of errors.
Let me paste my code.
While deleting row it throws exception.
"Connection property not initialized"
I have tried opening connection in different ways but it didn't help either. So can anyone tell me what can possibly wrong with this code?
Thanks
Ajinkya
I have written a code that could delete selected row in data grid view. I gives lots of errors.
Let me paste my code.
Code:
for (int i = 0; i < dataGridView1.Rows.Count; i++) { DataGridViewRow dr = dataGridView1.Rows[i]; if (dr.Selected == true) { dataGridView1.Rows.RemoveAt(i); cmd.CommandText = "Delete from transact1 where C_ID ='" + i + "'"; cmd.ExecuteNonQuery(); da.Update(ds, "transact1"); MessageBox.Show("Deleted"); } con1.Close(); }
While deleting row it throws exception.
"Connection property not initialized"
I have tried opening connection in different ways but it didn't help either. So can anyone tell me what can possibly wrong with this code?
Thanks
Ajinkya
Comment