Error Trapping dataAdapter.update

G

Guest

I have a data grid that keeps changes on a post back but does not persist the
changes to the underlying database. I dropped a sqlconnection and
sqldataadpater control at design time on to an ASP.NET page.
Here is my code:

Try
dataAdapter.Update(dataSet, "table")
Catch ex as sqlException
sError = ex.Message
End Try

Stepping through the code does not generate any errors. How can I find out
the reason the data does not save to the database? Any suggestions will be
appreciated.

Dan
 
M

Miha Markic [MVP C#]

Hi,

DLS said:
I have a data grid that keeps changes on a post back but does not persist
the
changes to the underlying database. I dropped a sqlconnection and
sqldataadpater control at design time on to an ASP.NET page.
Here is my code:

Try
dataAdapter.Update(dataSet, "table")
Catch ex as sqlException
sError = ex.Message
End Try

Stepping through the code does not generate any errors. How can I find out
the reason the data does not save to the database? Any suggestions will be
appreciated.

It is probably your table that doesn't have any suitable rows for update
(RowState == DataRowState.Unchanged).
You might try looking at dataSet.GetChanges() - it returns you all rows that
are pending update.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top