5
Answers

Updating in database with textboxes

Mark Fenech

Mark Fenech

13y
1.6k
1
Hi i am updating in database and im getting a "Object reference not set to an instance of an object" Exception.

This is my code :

   public void UpdateMember(DataGridView dgv, TextBox t1, TextBox t2, TextBox t3, TextBox t4, TextBox t5, TextBox t6)
        {
                int i = dgv.CurrentRow.Index;
          
                ds.Tables["dbo.tblMember"].Rows[i]["Name"] = t1.Text;
                ds.Tables["tblMember"].Rows[i]["Surname"] = t2.Text;
                ds.Tables["tblMember"].Rows[i]["Age"] = t3.Text;
                ds.Tables["tblMember"].Rows[i]["Address"] = t4.Text;
                ds.Tables["tblMember"].Rows[i]["Email"] = t5.Text;
                ds.Tables["tblMember"].Rows[i]["Number"] = t6.Text;

                da.Update(ds.Tables["tblMember"]);
                MessageBox.Show("Updating Completed", "Updating", MessageBoxButtons.OK, MessageBoxIcon.Information);
               
        }
Answers (5)
Next Recommended Forum