con.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand("select * from mytable where ID=" + Convert.ToInt32(textBox3.Text.ToString()), con); DataTable dt = new DataTable(); da.Fill(dt); // Till now all is working well ... dataGridView1.DataSource = dt.DefaultView; // Here i got the exception :( dt.Rows[0].BeginEdit(); dt.Rows[0][0] = Convert.ToInt32(textBox3.Text.ToString()); dt.Rows[0][1] = textBox4.Text.ToString(); dt.Rows[0].EndEdit(); SqlCommandBuilder cb = new SqlCommandBuilder(da); da.Update(dt); con.Close();
if( dt.Rows.Count > 0 ) { // ... Now do your stuff with it. }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)