473,508 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with updating table - Please respond

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"))
'

Nov 21 '05 #1
2 979
Hi

Try following:

daContact.update(ds)

regards
Stef

"Gary Paris" <ya**@test.com> schrieb im Newsbeitrag
news:OE**************@TK2MSFTNGP15.phx.gbl...
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"))
'

Nov 21 '05 #2
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.
"Stef" <sh*****@swissonline.ch> wrote in message
news:ck**********@newshispeed.ch...
Hi

Try following:

daContact.update(ds)

regards
Stef

"Gary Paris" <ya**@test.com> schrieb im Newsbeitrag
news:OE**************@TK2MSFTNGP15.phx.gbl...
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"))
'


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
15800
by: Otis Hunter | last post by:
I have been given an Access Database which contains a table that has an OLE object field that contains a Word document. That table contains hundreds of records. I would like to find out how I can...
3
12996
by: Tc | last post by:
Hi, I was curious, I am thinking of writing an application that loads a dataset from a database that resides on a server. The question I have is this, if multiple copies of the app will be...
0
2400
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView...
6
6424
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the...
15
2552
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
2
2083
by: Dave Ekhaus | last post by:
hi i'm new to javascript. i'm hoping to get some help and find out if what i want to do is possible and - assuming it is, get some tips on how to accomplish the task. ok - assume i have a...
8
2887
by: saladinator | last post by:
I have created an Excel spreadsheet that has a lot of data. What I want to do is import the spreedsheet to Access and create a form so that I can print each row per page in a proffessional manner....
0
878
by: phons | last post by:
Please help me with updating 2 separate tables simutaneously of MS Access using visual basic6.0 acutually both the table is connected to the same form. please help me sir.
14
6532
by: Mark | last post by:
I have a table with a field that uses a combobox to populate values. The Lookup tab within table design mode is the following: Display Control Combo Box Row Source Type ...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.