Note that there are some explanatory texts on larger screens.

plurals
  1. POSqlDataAdapter.Update silently fails
    primarykey
    data
    text
    <p>In my application, I have a control that displays the contents of a database table to the user. This control holds the data to display in a <code>System.Data.DataSet</code> object. The user is able to modify the data displayed in the control, and this data is then committed back into the database when the user is done.</p> <p>Problems occur when the data in the database table is modified by some external process (e.g. some rows have been updated) while the user is making edits in the control. Ignoring the issue of data correctness for the moment, what I would like to do is to commit the changes the user has made in the control and overwrite the changes made by this external process. </p> <p>I'm using a <code>SqlDataAdapter</code> to update the database. In the described use cases, when the underlying database table has not been modified by an external process, <code>SqlDataAdapter.Update</code> works as expected. However, in the scenario where some external process has fiddled with the table while the user was editing it then <code>SqlDataAdapter.Update</code> does not throw an exception but returns 0 indicating that no rows were updated. I've checked that rows in my dataset are have the correct data and <code>RowState</code> (i.e. <code>DataRowState.Modified</code>) so I know that the data I'm passing in to the <code>SqlDataAdapter.Update</code> method is correct.</p> <p>I suppose there are two parts to my question.</p> <ol> <li>Why is <code>SqlDataAdapter.Update</code> not updating the database with the specified dataset?</li> <li>Why is it silently failing?</li> </ol> <p>I have read <a href="http://blogs.msdn.com/b/spike/archive/2009/03/02/dataadapter-update-returns-0-and-doesn-t-update-the-table-in-sql-server.aspx" rel="nofollow">this blog entry</a>, and my code does not call <code>AcceptChanges</code> anywhere, and as I've stated above I have checked the <code>DataSet</code>'s <code>RowState</code> so I know that the rows are correctly marked as having modified data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload