N
new2.NET
Hi. I'm new to databinding and all that ADO.NET stuff. I
keep getting an object reference not set to an instance of
an object error. And if I try to create a new DataRow with
this code, I get the compiler error in the subject line. I
don't know how to handle this or how to change my code to
make it work. Below is my code which I cannot get to work.
'create a new row for the dataset
Dim rowNew As DataRow
rowNew = dsUser.Tables("User").NewRow()
'add data to the row
rowNew("userID") = txtUserID.Text
rowNew("userfName") = txtFirstName.Text
rowNew("userlname") = txtLastName.Text
rowNew("userDeptName") = txtDeptNumber.Text
rowNew("userEmail") = txtEmailAdd.Text
rowNew("userSupervisorID") = txtSuperID.Text
'add the row to the data set
dsUser.Tables("User").Rows.Add(rowNew)
'update database
adptUser.Update(dsUser, "User")
'rebind each text box to a different column in the
** code removed
dataset
Try
'modify the database
adptUser.Update(dsUser)
** code removed
Thanks in advance.
new2.NET
keep getting an object reference not set to an instance of
an object error. And if I try to create a new DataRow with
this code, I get the compiler error in the subject line. I
don't know how to handle this or how to change my code to
make it work. Below is my code which I cannot get to work.
'create a new row for the dataset
Dim rowNew As DataRow
rowNew = dsUser.Tables("User").NewRow()
'add data to the row
rowNew("userID") = txtUserID.Text
rowNew("userfName") = txtFirstName.Text
rowNew("userlname") = txtLastName.Text
rowNew("userDeptName") = txtDeptNumber.Text
rowNew("userEmail") = txtEmailAdd.Text
rowNew("userSupervisorID") = txtSuperID.Text
'add the row to the data set
dsUser.Tables("User").Rows.Add(rowNew)
'update database
adptUser.Update(dsUser, "User")
'rebind each text box to a different column in the
** code removed
dataset
Try
'modify the database
adptUser.Update(dsUser)
** code removed
Thanks in advance.
new2.NET