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. 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.
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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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 ...
|
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...
|
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.
...
|
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....
|
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....
|
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 =...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |