Problem with dataset in .NET 2.0 Update requires a valid UpdateCom

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I have a typed dataset on a Windows form on Smart Device Application that
displays data from a Sql Server Mobile database.

The problem is, whenever I want to add a new record I first make a call to:

myTableBindingSource.AddNew();

and this inserts a blank row.

When I've completed editing I make a call to:

myTableBindingSource.EndEdit();
myTableTableAdapter.Update(myDataSet.myTable);

and this works fine, no problems at all.


However, when I load the form and want to edit an existing record and not
add a new one... the Update command fails with:

"Update requires a valid UpdateCommand when passed DataRow collection with
modified rows"


I'm pretty sure this is something pretty basic I've missed. I've tried
making calls to myDataSet.myTable.AcceptChanges() but this doesn't work
either. I know that it's because the Update statement on the
myTableTableAdapter object isn't being initialized correctly.

Does anyone know how to make sure the Update command is generated correctly
and the changes can be persisted back into the database?

Thanks,

Shaun O'Callaghan
 
Bear in mind that when you are using SQL mobile the database path that you
set is in the mobile device and not your development machine.

chanmm
 
Back
Top