Monday 29 July 2013

delete in gridview

try
            {
                int id = Convert.ToInt32(dataGridView1.CurrentRow.Index.ToString());

                cid =Convert.ToInt32( dataGridView1.Rows[id].Cells[0].Value.ToString());
                OleDbCommand cmd = new OleDbCommand("delete * from customer where id="+cid+"", con);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                gridshow();
               

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

No comments:

Post a Comment