Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataSet updates ... VB.NET, VS 2010

Status
Not open for further replies.

JScannell

Programmer
Jan 9, 2001
306
US
I have a dataset that I created using the dataset designer. After going through the configuration steps in tyhe TableAdapter Configuration Wizard (), it said that it created insert, update, and delete methods based on the select query.

However, at runtime, the method: Me.UpdateUpdatedRows ( dataSet, allChangedRows, allAddedrows ) results in this exception: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.

Someone in another post siad that the update method wasn't created. how can that be if the designer wizard said it did? If I have to add one muyself, how do I do it via the wizard?

This is all for a desktop application.

Hopefully you can retrieve the Word Document I left on a website of mine.

Thanks in advance,

Jerry Scannell
 
 http://www.kofcri.org/documentation/DataSet configuration Screenshots.docx
In the dataset designer go to the tableadapter and click on your tabledapter label for that datatable. Look in the properties window. Scroll to the bottom to the "Data" block. There should be properties for connection, deletecommand, insertcommand, selectcommand, and updatecommand. Expand the update command and you should have properties for command text, commandtype, and parameters. Post your command text.

My guess is your problem is that you built your datatable off of a join query. In that case it cannot build update queries, insert, and delete. No way for the system to figure it out. When working in ADO.NET you should try always to mirror your datatables to your actual tables if you plan to do more than view the data. In ADO.net programming the Author Dave Sceppa has a good discussion of "getting away from join queries", and leveraging things like expression fields.

You are using a table adapter manager and I usually manage my own. My understanding is that the TAM calls the individual adapters and commands in the correct order (delete, insert, update for both the parent and child tables), but that does not mean you can write a single update command for a select query based off of a Join.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top