473,786 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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).Ro ws
'Manipulate the data here - - asign First to sFirst and Last to sLast
variables (working perfectly)
'I then populate the update command:
UpDateSQL="Upda te Registered set Fname = '" & sFirst & "', Lname='" & sLast
& "' where ID = " & iID
Dim upDateCmd as New SqlCommand(Upda teSQL, MyConn)
UpdateCmd.Comma ndText=UpDateSQ L
Trace.Warn ("commandTex t = " & UpdateCmd.Comma ndText) <---- 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 1213
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**********@y ahoo.com> wrote in message
news:uf******** *****@TK2MSFTNG P10.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).Ro ws
'Manipulate the data here - - asign First to sFirst and Last to sLast
variables (working perfectly)
'I then populate the update command:
UpDateSQL="Upda te Registered set Fname = '" & sFirst & "', Lname='" & sLast & "' where ID = " & iID
Dim upDateCmd as New SqlCommand(Upda teSQL, MyConn)
UpdateCmd.Comma ndText=UpDateSQ L
Trace.Warn ("commandTex t = " & UpdateCmd.Comma ndText) <---- 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*****@aboutf ortunate.com> wrote in message
news:%2******** **********@TK2M SFTNGP10.phx.gb l...
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**********@y ahoo.com> wrote in message
news:uf******** *****@TK2MSFTNG P10.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).Ro ws
'Manipulate the data here - - asign First to sFirst and Last to sLast
variables (working perfectly)
'I then populate the update command:
UpDateSQL="Upda te Registered set Fname = '" & sFirst & "', Lname='" &

sLast
& "' where ID = " & iID
Dim upDateCmd as New SqlCommand(Upda teSQL, MyConn)
UpdateCmd.Comma ndText=UpDateSQ L
Trace.Warn ("commandTex t = " & UpdateCmd.Comma ndText) <---- 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
4272
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 underline. It was working fine before. ConnectionString in Web.config: ----------------------------------------- <?xml version="1.0" encoding="utf-8" ?> <configuration>
6
1579
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 from there. I can't find a way to do this. Am I missing something? Much obliged.
13
2091
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 OleDbCommand with an SQL String and the connection it has a DataAdapter with the command then it fills the DataSet's DataTable with the streamed data.
1
2316
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 - Date/Time TimeOpened - Date/Time
11
2252
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 reflect that the 3 items have been deleted only to discover that the 3 items appear, however when I click on them to display their information which runs a datareader over the same database it appears that the data has now gone. I wondered whether...
8
2698
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. Example: I have a dataadapter that contains one table with one row. I change the value of the 'FisrtName' column in that row from Jack to John. I call ..update on the dataadapter it goes through fine. Now I change that same column in that same row...
1
1433
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. strings). The problem is whenever I try to test the webservice I get: System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure...
2
1895
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. strings). The problem is whenever I try to test the webservice I get: System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure...
6
14002
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 = conn da.UpdateCommand.CommandText = "Update tbl1 set fld1 = 'test' where ID = 1" da.Update(tblx) '--tblx/tbl1 not getting updated here.
2
2898
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 following exception: Incorrect syntax near ','. Must declare scalar variable "@ContactID". Here's the code: private void btnSave_Click (object sender, EventArgs e) { DataRow row = dataTable.Rows ; ...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9496
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8989
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
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 we have to send another system
3
2894
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.