Mark Fenech

Mark Fenech

  • NA
  • 82
  • 69.2k

Updating in database with textboxes

Apr 27 2011 6:02 AM
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)