Hello everyone, I insert the datagridview control and I link it with a datasource but I stuck to the update with this datagridview when inserting new line in database?


Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sourabh SomaniRank #37 · 35.5K reputationPosted Nov 16, 2015, 6:01 AM EST
abdelwaheb ammarRank #4,571 · 337 reputationPosted Nov 16, 2015, 6:10 AM EST
Sourabh SomaniRank #37 · 35.5K reputationPosted Nov 16, 2015, 6:28 AM EST
abdelwaheb ammarRank #4,571 · 337 reputationPosted Nov 16, 2015, 6:33 AM EST
Sourabh SomaniRank #37 · 35.5K reputationPosted Nov 16, 2015, 6:38 AM EST
abdelwaheb ammarRank #4,571 · 337 reputationPosted Nov 16, 2015, 6:45 AM EST
Rupali ShindeRank #539 · 4.5K reputationPosted Nov 16, 2015, 8:00 PM EST
private void bindgrid() { OleDbConnection con = new OleDbConnection(ConnectionString); con.Open(); str = "select * from employee"; com = new OleDbCommand(str, con); oledbda = new OleDbDataAdapter(com); ds = new DataSet(); oledbda.Fill(ds, "employee"); dataGridView1.DataMember="employee"; dataGridView1.DataSource = ds; con.Close(); }OleDbConnection con = new OleDbConnection(ConnectionString); con.Open(); str = "Update employee set sno=@sno,name=@name,address=@address,age=@age Where sno=@sno"; com = new OleDbCommand(str, con); com.Parameters.AddWithValue("@sno", txt_sno.Text); com.Parameters.AddWithValue("@name", txt_name.Text); com.Parameters.AddWithValue("@address", txt_address.Text); com.Parameters.AddWithValue("@age", txt_age.Text); com.ExecuteNonQuery(); MessageBox.Show("Record Successfully Updated"); con.Close(); bindgrid(); }Rupali ShindeRank #539 · 4.5K reputationPosted Nov 16, 2015, 8:05 PM EST