yireh
asked on
Adding Record Problem
Hi:
I'm new to vb.net. I'm programmer of VB6
I'm trying to add new record to sql table called "Users" and have an error message.
The Code used is;
Dim strQuery As String = "Select * From Users"
Dim ds As New DataSet("Users")
Dim da As New SqlClient.SqlDataAdapter(s trQuery, dbConn)
da.Fill(ds)
Dim dr As DataRow = ds.Tables(0).NewRow
dr.Item("USER_ID") = "data"
dr.Item("PASSWORD") = "data2"
dr.EndEdit()
ds.Tables(0).Rows.Add(dr)
da.Update(ds, "Users") '****>>> Update unable to find TableMapping['Users'] or DataTable 'Users'.
Thanks in advance for your help.
I'm new to vb.net. I'm programmer of VB6
I'm trying to add new record to sql table called "Users" and have an error message.
The Code used is;
Dim strQuery As String = "Select * From Users"
Dim ds As New DataSet("Users")
Dim da As New SqlClient.SqlDataAdapter(s
da.Fill(ds)
Dim dr As DataRow = ds.Tables(0).NewRow
dr.Item("USER_ID") = "data"
dr.Item("PASSWORD") = "data2"
dr.EndEdit()
ds.Tables(0).Rows.Add(dr)
da.Update(ds, "Users") '****>>> Update unable to find TableMapping['Users'] or DataTable 'Users'.
Thanks in advance for your help.
This is assuming that the there is nothing wrong with the dataadapter. But make sure you replace ds for dt.
jtaylor8181
jtaylor8181
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try
Dim dt as New DataTable("User")
Also, sometimes you have to use a different name from the actual database table for the datatable or dataset.
jtaylor8181