SqlDataAdapter da;
SqlCommandBuilder cmd;
DataSet ds;
private void Form1_Load(object sender, EventArgs e)
{
da = new SqlDataAdapter("select * from emp","Connection string");
cmd = new SqlCommandBuilder(da);
ds = new DataSet();
da.Fill(ds,"myemp");
dataGridView1.DataSource = ds.Tables[0];
}
private void delete_Click(object sender, EventArgs e)
{
int position = 0;
foreach (DataRow item in ds.Tables["myemp"].Rows)
{
if(item["id"].ToString() == textBox1.Text)
break;
position++;
}
ds.Tables["myemp"].Rows[position].Delete();
da.Update(ds.Tables["myemp"]);
MessageBox.Show("successful");
}