Help with updating table - Please respond

G

Gary Paris

I am trying a test. I want to update one Last Name to "Smith". How can I
do this? What code is missing?

Dim con As New
SqlClient.SqlConnection("server=TESTSERVER;uid=sa;pwd=;database=ServiceMaster")

Dim daContact As New SqlClient.SqlDataAdapter("SELECT first_name,
last_name From Contact ORDER BY last_name, first_name", con)

Dim ds As New DataSet
daContact.Fill(ds, "Contact")

Dim tbl As DataTable = ds.Tables(0)
Dim row As DataRow

row.BeginEdit()
ds.Tables("Contact").Rows(1).Item("last_name") = "Smith"
row.EndEdit()

' *********** IS THIS CORRECT *********** Not sure
'daContact.Update(ds.Tables("Contact"))
'
 
G

Gary Paris

I tried the update you suggested but received the following error:

update unable to find TableMapping ['Table'] or DataTable 'Table'

so I changed the command to: daContact.update(ds.tables(0))

and received the following error:

update requires a valid Update Command when passed DataRow collection with
modified rows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top