MySqlCommandBuilder difficulties (while updating)
Posted by: Nico den Boer
Date: January 25, 2005 03:56PM

Hi all, a newbee question...

I'm trying to update my data, but the .Update() method returns 0 rows affected and no exceptions.

I have a table with primary key defined.

This is the code to retrieve data:
DataSet ds = new DataSet();
MySqlDataAdapter da = new MySqlDataAdapter(m_selectSql, m_connString);
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da.Fill(ds);

So far, so good. My data is displayed properly.

Then I try to update:
if (da.SelectCommand.Connection.State != ConnectionState.Open)
da.SelectCommand.Connection.Open();
// da.FillSchema(Dt, SchemaType.Source);
da.ContinueUpdateOnError = true;
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
//cb.RefreshSchema();
RowsChanged = da.Update(ds, TableName); // always returns 0
if (da.SelectCommand.Connection.State == ConnectionState.Open)
da.SelectCommand.Connection.Close();
cb.Dispose();

I have tested FillSchema() with no better results.
Also tested
da.InsertCommand = cb.GetInsertCommand();
da.UpdateCommand = cb.GetUpdateCommand();
da.DeleteCommand = cb.GetDeleteCommand();
but with no better results.

What did I miss ?

Any feedback would be greatly appreciated...

Kind regards,
Nico den Boer

Options: ReplyQuote


Subject
Written By
Posted
MySqlCommandBuilder difficulties (while updating)
January 25, 2005 03:56PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.