Update Record
Update Record
Update Record
Update Record
Update Record
Update Record Update Record Update Record Update Record Update Record Update Record Update Record Update Record
Update Record Update Record
Update Record
Go Back  Xtreme Visual Basic Talk > > > Update Record


Reply
 
Thread Tools Display Modes
  #1  
Old 03-31-2014, 08:35 AM
sirmilt sirmilt is offline
Contributor
 
Join Date: Jan 2003
Location: Florida
Posts: 451
Unhappy Update Record


I am using Visual Basic 2012 Express and SQL Server 2005 Express.

I am using the DataAdapter to fill or modify a database table the code is below.
Code:
Try Me.Validate() Me.TblBooksBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.MyCollectionsDataSet) If boIsNewBook = True Then lblResults.Text = "The book " & TitleTextBox.Text & " has been successfully entered into the Books database." Else lblResults.Text = "Changes to the book " & TitleTextBox.Text & " have been saved to your database." End If Catch ex As Exception MsgBox("Update failed") End Try
When I test the code, it inserts a new record perfectly. Unfortunately, when I try to modify a record, the same cose throws an error . The catch error content is " Update requires a valid UpdateCommand when passed DataRow collection with modified rows."

I'm lost, there is an update command....what am I missing?

Milt

Last edited by Gruff; 04-04-2014 at 09:44 AM.
Reply With Quote
  #2  
Old 04-03-2014, 09:38 AM
loquin's Avatar
loquinUpdate Record loquin is offline
Google Hound

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,400
Default

Well, the error says "Update requires valid UpdateCommand." If I had to guess (and I do, because you haven't provided any of the code or the text of the updatecommand,) I would say there's a problem with the UpdateCommand.
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Reply With Quote
  #3  
Old 04-03-2014, 07:42 PM
sirmilt sirmilt is offline
Contributor
 
Join Date: Jan 2003
Location: Florida
Posts: 451
Default

The code recommended by Microsoft is in my original post.
Reply With Quote
  #4  
Old 04-04-2014, 06:46 AM
PlausiblyDamp's Avatar
PlausiblyDampUpdate Record PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

When you created the dataset did you tell the wizard to create the Insert, Update and Delete commands? If not that would explain why you don't have an UpdateCommand.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #5  
Old 04-04-2014, 08:08 AM
sirmilt sirmilt is offline
Contributor
 
Join Date: Jan 2003
Location: Florida
Posts: 451
Default

Please see my original post. There is an update command,

Milt
Reply With Quote
  #6  
Old 04-07-2014, 10:48 AM
loquin's Avatar
loquinUpdate Record loquin is offline
Google Hound

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,400
Default

Every datadapter has an updatecommand, but the updatecommand has a command string property which contains text, along the lines of "Update [yourtablename] ... "

Either you have to supply the string explicitly, or you have to specify that the wizard does.

Because of the error, it appears that this had not been done.
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Reply With Quote
  #7  
Old 04-08-2014, 08:01 AM
sirmilt sirmilt is offline
Contributor
 
Join Date: Jan 2003
Location: Florida
Posts: 451
Default

Thank you all, for the responses.

Milt
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Update Record
Update Record
Update Record Update Record
Update Record
Update Record
Update Record Update Record Update Record Update Record Update Record Update Record Update Record
Update Record
Update Record
 
Update Record
Update Record
 
-->