The error states : Update requires a valid UpdateCommand when passed
DataRow Collection with modified rows.
I chose generat INSERT DELETE UPDATE methods when I created the dataset. Why am I getting this error
This is the line of code (in red) that fails:
public virtual int Update(CellcastBackEndDataSet.tblShiftDataTable dataTable) { return this.Adapter.Update(dataTable);
}
Thanks
Thanks

More Table Adapter problems.
wsaunders
The error occurs on calls to DataAdapter.Update if your DataAdapter does not contain updating logic. The Visual Studio .NET design-time tools should generate this logic for you.
Generally speaking, if you want Visual Studio .NET to generate updating logic, you should make sure your query references a single table, that table has a primary key, and the primary key appears in the results of your query.
I'd like to reproduce the behavior you're seeing. If you could provide information about the type of database you're using, how you're connecting, the structure of the table(s) you're querying and the query itself, someone may be able to help.
jaytman123
nss_2001
Thanks very much!
I spent 4 days~! ah~~ maybe it was my mistake.
Bobo78
I still got a problem.
with below codes...
// Use dataTable method.
dbTestDataSet.forTestDataTable testTable = new dbTestDataSet.forTestDataTable();
testAdapter.Fill(testTable);
for (int i = 0; i < 10; i++)
{
dbTestDataSet.forTestRow dRow = testTable.NewforTestRow();
dRow.tTitle = "DataTable" + i;
testTable.AddforTestRow(dRow);
}
testTable.AcceptChanges();
int result = 0;
try
{
result = testAdapter.Update(testTable); // Update.
}
catch
{
MessageBox.Show("error occurred");
}
above code may have a result to insert 10 records in the Database.
But, it does not work. ( testAdapter.Update result is '0'.)
My program already has...
1. DeleteCommand, UpdateCommand in TableAdapter properties.
2. It works when I use TableAdapter.Insert() method directly (without DataTable object).
3. I can see testTable.AccepChanges() has updated result.
4. I, of course has Primary Key, and DB copy set to 'Copy if newer'.
Can you help me with my problem
I sent email with VS project file to David.
Silverback
Hello everyone,
The question taht might be asked is what database are you working on It took me 2 hours of tinkering and could not get this update feature work. I deleted teh main form lost everything :(and still had the same problem.
I am working off an Access database and I found as some posts have suggested you need a primary key.
Good luck with it
Joe
Kiran Juikar
You can check to see if your TableAdapter has complete updating logic by opening the strongly-typed DataSet in the designer and selecting the TableAdapter. Look in the Properties window. If the UpdateCommand and DeleteCommand are set to "(none)", then the TableAdapter wizard failed to generate the logic required to submit pending modifications or deletions.
You can perform a similar check using the Intellisense drop-downs in your code. If the TableAdapter does not expose a Delete method or a strongly-typed Update method (one that takes parameters based on your column names, then the TableAdapter wizard failed to generate the logic required to submit pending modifications or deletions.
The likely cause for the behavior is a lack of a primary key on the table referenced by the TableAdapter's SelectCommand.
I hope this information proves helpful.
Philip Alexander Hassialis
I have a similar problem, but my table has all the proerties set for all the commands including insert and update.
Below is the code.
Public
Class SiteConMain Private Sub DbProjectsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DbProjectsBindingNavigatorSaveItem.Click Try Me.Validate() Me.DbProjectsBindingSource.EndEdit() Me.DbProjectsTableAdapter.Update(Me.DsSiteCon.dbProjects)MsgBox(
"Update successful") Catch ex As ExceptionMsgBox(
"Update failed") End Try End Sub Private Sub SiteConMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'DsSiteCon.dbProjects' table. You can move, or remove it, as needed. Me.DbProjectsTableAdapter.Fill(Me.DsSiteCon.dbProjects) End SubEnd
ClassPlease assist
Nishith Pathak
I think that I've worked out (after 6 hours of tinkering reading and the obligitory swearing) that you need to set the UPDATE as well as the INSERT commands to add records. INSERT alone is not enough.
tom_davies
PureCode
hope this helps
steve
danprime
I am afraid that this also means that TableAdapters do not work with views at all. And it is not enough to configure the primary key in the .XSD file, it has to be in the database. One wonders why this nice concept was implemented in such a way that renders is unusable. I never let users access tables directly for security reasons, I this means I cannot use TableAdapters. Right I hate it!
StephenW
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=125583&SiteID=1
SKB2006
Remove the call to testTable.AcceptChanges(). That method call tells the DataTable to accept all of the pending changes in the DataTable and mark those rows as Unchanged. As a result, your call to testAdapter.Update finds no pending changes in the DataTable, executes no queries to submit changes to your database, and simply returns 0.
You would see the same behavior with standard DataAdapters and is unrelated to TableAdapters.