Updating a Table Adapter  
Author Message
mike Delaney





PostPosted: .NET Framework Data Access and Storage, Updating a Table Adapter Top


Updating Data from a table Adapter

Honestly I do not understand why I need to write code to update a databse and why it stores it localy. I'd simply rather the system update the individual row after it is scrolled off of.

In either case since I guess I can't do that.

Here is some code in a button on a form

Try

ItemsTableAdapter.Update(NewCreationsDataSet1.Items)

LineCodeTableAdapter.Update(NewCreationsDataSet1.LineCode)

Catch ex As Exception

MsgBox(ex.Message)

End Try

I get an error stating

"Update Requires a Valid Update Command when passed a dataRow collection with modified rows"

Do I need to include each column in the update command



.NET Development36  
 
 
TkNeo





PostPosted: .NET Framework Data Access and Storage, Updating a Table Adapter Top

Seems like there is an error in the Table Adaptor's Update command. Did you write the command on your own Or did the dataset designer create automatically for you. There is a way to test the update command. Click on execute query. It will ask for populating the parameters. Enter the parameters and see what happens. If it doesn't work post your update command.
 
 
mike Delaney





PostPosted: .NET Framework Data Access and Storage, Updating a Table Adapter Top

It was auto generated. Also the update command does not show up on the Table adapter in the dataset... Yes the table is keyed.
 
 
William Vaughn





PostPosted: .NET Framework Data Access and Storage, Updating a Table Adapter Top

So you did set a PrimaryKey on the table, your SELECT query only references a single table without expressions, and you're using a DBMS provider that supports updates like SQL Server, JET, Oracle or the such.

 
 
mike Delaney





PostPosted: .NET Framework Data Access and Storage, Updating a Table Adapter Top

SQL Server 2000.


 
 
mike Delaney





PostPosted: .NET Framework Data Access and Storage, Updating a Table Adapter Top

All of the code is Auto generated. I selected the options to generate individual row update deletes and the concurrency option. I'm simply testing VS 2005 in preparation for a large project that I am designing. No big coding at all right now just a form a database and a dataset.
 
 
TkNeo





PostPosted: .NET Framework Data Access and Storage, Updating a Table Adapter Top

The only reason dataset designer does not generate update statements for a table is when you select columns, none of which is a primary key. Delete the table and reconfigure your dataset. make sure you select a primary key column.
 
 
mike Delaney





PostPosted: .NET Framework Data Access and Storage, Updating a Table Adapter Top

FYI I guess this has been a request for quite sometime.

Suggestion Details: Automatic Update of database is a DataRow changes

Suggestion ID: FDBK44764
Problem Type: Suggestion
Status: New
Microsoft Status: Under Review
Opened Date: 2006-01-26 23:48:03
Opened By: Peter Huber
Product/Technology: .NET Framework
Version: Visual Studio 2005
Product Language: English
Category: Data
OS: Windows XP Professional
OS Language: US English


 
 
Aluizio





PostPosted: .NET Framework Data Access and Storage, Updating a Table Adapter Top

Yes!!!

you solve my problem...

congratulations, you are the one.

Tanks.