Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2010 > BOOK: Visual Basic 2010 Programmer's Reference
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Visual Basic 2010 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2010 Programmer's Reference by Rod Stephens; ISBN: 9780470499832
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2010 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 28th, 2013, 01:06 PM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2013
Location: Tampa Bay
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default Update requires a valid UpdateCommand

I am using the Chapter 20 example in order to link a simple Textbox to table in an Access Database (I have other forms in my program that do this manually, but I just downloaded the book and wanted to try having VS2010 do some of the work instead).

Here are the steps that I did to re-create the example.
1) I added a Dataset Class to my Project and titled it CDInformation
2) I dragged the table CDInfo from my linked Database to the Dataset configuration
3) I dragged the field: CDName from the Dataset onto the Form

When I run the program, the data from the table appears correctly in the form.
However, when I click on the Update button, I get the following error on the line:
Code:
Me.TableAdapterManager.UpdateAll(Me.CDInformation)
Update requires a valid UpdateCommand when passed DataRow collection with modified rows

I'm familiar with the UpdateCommand because I'm using it in another form, however in order to declare the command "builder", I would need to add the line:
Code:
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(<oledbdataadpatername>)
And I get an error when I try and add this to the program.
I'm sure that I've got some mismatch in my DataSet's definition of the Solution Explorer, but I'm not sure what I'm looking for.
If anyone has any idea, I'd greatly appreciate it.
Thank for your time in advance,
Paul Goldstein
Forceware Systems, Iinc.
Reply With Quote
  #2 (permalink)  
Old January 29th, 2013, 10:27 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,141, Level: 23
Points: 3,141, Level: 23 Points: 3,141, Level: 23 Points: 3,141, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 640
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I don't know if I've done exactly this so this is a bit of a guess, but I think the TableAdapterManager has a property named after each table. In this case, there should be a CDInfoTableAdapter property. Try passing that to the OleDbCommandbuilder constructor as in:

Code:
Dim builder As OleDbCommandBuilder =
    New OleDbCommandBuilder(Me.TableAdapterManager.CDInfoTableAdapter)
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
  #3 (permalink)  
Old January 29th, 2013, 11:07 AM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2013
Location: Tampa Bay
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Rod,
Thanks for responding.
I just tried inserting that Dim statement into my program (I thought I tried it yesterday, the code that the Editor helped to generate looks like this):
Code:
Dim cbCDInfo As OleDb.OleDbCommandBuilder = New OleDbCommandBuilder(Me.TableAdapterManager.tblCDInfoTableAdapter)
anyway, I'm receiving an error as soon as I insert the code:
Value of type 'WindowsApplication1.CDInformationTableAdapters.tb lCDInfoTableAdapter' cannot be converted to 'System.Data.oleDB.oleDBDataAdapter'

Again, the example from Chapter 20, does not use a CommandBuilder statement. I downloaded the code and ran the example and it executes fine. I've tried comparing all of my declarations against what the example has, so that's where I'm out. I thought someone that's seen this before would know why I don't need a CommandBuilder in order to update the Table.

Thanks again,
Paul
Reply With Quote
  #4 (permalink)  
Old January 29th, 2013, 02:20 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,141, Level: 23
Points: 3,141, Level: 23 Points: 3,141, Level: 23 Points: 3,141, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 640
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I think the original example didn't use the TableAdapterManager, did it? I think it made most of its connections with wizards and I think the wizards set up the commands. (Although it's been a while since I've looked at that example.)

Does the tblCDInfoTableAdapter object have any useful properties? Or is it derived from OleDbAdapter or some other kind of adapter that you can somehow convert? (Just guessing in the dark here.)

This is one area where Microsoft can't leave well enough alone. They get a workable solution going and then every year they decide to rewrite everything from scratch so you need to learn to use a whole new set of objects to control databases, datasets, adapters, managers, currency managers, etc. It's extremely frustrating. I think their latest attempt to make life "easier" is data objects.

Unfortunately not too many people read this forum. Mostly people who have a specific question. If you want a larger audience to help, you should probably post on one of the Microsoft forums.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
  #5 (permalink)  
Old January 29th, 2013, 02:40 PM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2013
Location: Tampa Bay
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Well I did drag the Dataset from the Database window like the book said...and it did add the: BindingSource, TableAdapter, TableAdapterManager, and BindingNavigator to the Form...so I'll try and see if there's some property that I'm missing that's not matching the Example to my App.
BTW, I downloaded the book onto my iPad...Barnes and Noble had nothing in the store (I could download something else from B&N it into my Nook app on the Pad). There really is no true manual that comes with VS2010 like when you used to purchase Software in a store...I bought Access1.0 when it first come out the day before Thanksgiving in 1992 (Egghead) and it came with about 3-4 different manuals that where a total of about 4-5in thick.
So rather Google'ing and asking questions on the MS Forums (and trying to decipher some of the C syntax in the Help file...which could use a lot more VB examples)...I finally decided to find a book.
The real problem on the MS forums is that if someone sees your post, and they recognize 1 or 2 keywords in your post...they post some example which has nothing to do with what you're looking for.
I'm actually converting a VB5.0 program that I wrote about 10 years ago where the syntax used Datasets and the syntax was almost exactly like the VBA in Access. Luckily I have a degree in CS so a lot of this is still just theory and I can adapt.
Thanks again for your help.
Paul
Reply With Quote
  #6 (permalink)  
Old January 29th, 2013, 04:22 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,141, Level: 23
Points: 3,141, Level: 23 Points: 3,141, Level: 23 Points: 3,141, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 640
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I know what you mean. Now days instead of a manual they post a zillion help pages that can sometimes be hard to decipher or even find. And they assume authors will write books you can use instead of a manual. It's sometimes inconvenient for developers but I can see their reasoning. It's a lot easier for them this way and they can post revisions as needed.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView UpdateCommand Sheraz Khan ASP.NET 2.0 Professional 2 August 28th, 2007 07:24 AM
Error: Update requires a valid InsertCommand ... spiffyaldo2 ASP.NET 2.0 Basics 3 March 27th, 2006 01:24 AM
Error: Update requires a valid InsertCommand... spiffyaldo2 ASP.NET 1.0 and 1.1 Basics 0 March 25th, 2006 01:28 PM
Update requires a valid InsertCommand when ... spiffyaldo2 BOOK: Beginning ASP.NET 1.0 0 March 25th, 2006 02:05 AM
UpdateCommand ozzy VB.NET 2002/2003 Basics 4 January 24th, 2005 04:55 PM



All times are GMT -4. The time now is 04:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.