473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DataAdapter/Update problem

I've got a situation where I'm trying to fix an existing table - - The Fname
Field has both First & Last Names...

So - I've populated a Dataset with the ID, First and Last names - - -

I'm iterating through the datatable, Fixing the datat and assigning the
First and Last name to variables, which I then, want to use to update the
first and last name fields with.

I keep getting an error when I try to do the Update on the row:
"Update requires a valid UpdateCommand when passed DataRow collection with
modified rows. "

So far, here's what I've got :
For Each MyRow in ds.Tables(0).Rows
'Manipulate the data here - - asign First to sFirst and Last to sLast
variables (working perfectly)
'I then populate the update command:
UpDateSQL="Update Registered set Fname = '" & sFirst & "', Lname='" & sLast
& "' where ID = " & iID
Dim upDateCmd as New SqlCommand(UpdateSQL, MyConn)
UpdateCmd.CommandText=UpDateSQL
Trace.Warn ("commandText = " & UpdateCmd.CommandText) <---- this shows up
perfectly - exactly what is needed to update the table

da.Update(ds, "Registered") <-- error occurs here

What's wrong here?

Apparently I'm missing something, but I don't have the slightest idea what
it is.

Nov 17 '05 #1
2 1196
Elmo,

Skip all the code and just modify your SQL instead.

SELECT (LastName + ", " + FirstName) AS FullName FROM tblNames

With the code above your database will return a column "FullName" to the
dataset and you're done.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Elmo" <sp**********@yahoo.com> wrote in message
news:uf*************@TK2MSFTNGP10.phx.gbl...
I've got a situation where I'm trying to fix an existing table - - The Fname Field has both First & Last Names...

So - I've populated a Dataset with the ID, First and Last names - - -

I'm iterating through the datatable, Fixing the datat and assigning the
First and Last name to variables, which I then, want to use to update the
first and last name fields with.

I keep getting an error when I try to do the Update on the row:
"Update requires a valid UpdateCommand when passed DataRow collection with
modified rows. "

So far, here's what I've got :
For Each MyRow in ds.Tables(0).Rows
'Manipulate the data here - - asign First to sFirst and Last to sLast
variables (working perfectly)
'I then populate the update command:
UpDateSQL="Update Registered set Fname = '" & sFirst & "', Lname='" & sLast & "' where ID = " & iID
Dim upDateCmd as New SqlCommand(UpdateSQL, MyConn)
UpdateCmd.CommandText=UpDateSQL
Trace.Warn ("commandText = " & UpdateCmd.CommandText) <---- this shows up
perfectly - exactly what is needed to update the table

da.Update(ds, "Registered") <-- error occurs here

What's wrong here?

Apparently I'm missing something, but I don't have the slightest idea what
it is.

Nov 17 '05 #2
Sorry - it's just the opposite I need - -
The full name is actually in the Fname field (I know - don't ask why - that
was before me) - - now
I'm trying to split that up into the first & last name fields.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Elmo,

Skip all the code and just modify your SQL instead.

SELECT (LastName + ", " + FirstName) AS FullName FROM tblNames

With the code above your database will return a column "FullName" to the
dataset and you're done.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Elmo" <sp**********@yahoo.com> wrote in message
news:uf*************@TK2MSFTNGP10.phx.gbl...
I've got a situation where I'm trying to fix an existing table - - The

Fname
Field has both First & Last Names...

So - I've populated a Dataset with the ID, First and Last names - - -

I'm iterating through the datatable, Fixing the datat and assigning the
First and Last name to variables, which I then, want to use to update the first and last name fields with.

I keep getting an error when I try to do the Update on the row:
"Update requires a valid UpdateCommand when passed DataRow collection with modified rows. "

So far, here's what I've got :
For Each MyRow in ds.Tables(0).Rows
'Manipulate the data here - - asign First to sFirst and Last to sLast
variables (working perfectly)
'I then populate the update command:
UpDateSQL="Update Registered set Fname = '" & sFirst & "', Lname='" &

sLast
& "' where ID = " & iID
Dim upDateCmd as New SqlCommand(UpdateSQL, MyConn)
UpdateCmd.CommandText=UpDateSQL
Trace.Warn ("commandText = " & UpdateCmd.CommandText) <---- this shows up perfectly - exactly what is needed to update the table

da.Update(ds, "Registered") <-- error occurs here

What's wrong here?

Apparently I'm missing something, but I don't have the slightest idea what it is.



Nov 17 '05 #3

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

Similar topics

2
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third...
6
by: Geoff Pennington | last post by:
I have a class method that returns a DataAdapter. I want to access the table(s) contained in the DataAdapter. Of course, accessing the DataSets would be good enough, because I could get the tables...
13
by: Doug Bell | last post by:
Hi, I thought I had this sorted this morning but it is still a problem. My application has a DataAccess Class. When it starts, it: Connects to a DB (OLE DB) If it connects it uses an...
1
by: mivey4 | last post by:
Okay, The problem is that I have an Access Database that has the following fields: EmpID - Autonumber (PrimaryKey) AccountID - Text IssueReported - Memo DateOpened ...
11
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
1
by: Franklin M. Gauer III | last post by:
I create a simple DATAADAPTER in a webservice project. It creates the UPDATE, INSERT, DELETE commands for me - no problem. In vS2005 it creates these commands as RESOURCES in the RESX file (i.e....
2
by: Franklin M. Gauer III | last post by:
I create a simple DATAADAPTER in a webservice project. It creates the UPDATE, INSERT, DELETE commands for me - no problem. In vS2005 it creates these commands as RESOURCES in the RESX file (i.e....
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
2
by: BobLewiston | last post by:
I can read in an SQL table ("Person.Contact") from AdventureWorks and step through it one row at a time, but when I try to save a record, either one I'm inserting or one I'm editting, I get the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.