Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataAdapter/Update problem

Reply
Thread Tools

DataAdapter/Update problem

 
 
Elmo
Guest
Posts: n/a
 
      11-08-2003
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.



 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      11-08-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
>
>



 
Reply With Quote
 
 
 
 
Elmo
Guest
Posts: n/a
 
      11-08-2003
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" <(E-Mail Removed)> wrote in message
news:%232c%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.
> >
> >
> >

>
>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments