Simple Update Question

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Hi,

Newbie to ADO.NET - I am trying to save updated from my
VB.NET client back to the SQL Server database. This is my code:

Try
daInvData.Update(dsInvestigation.dtPersonInfo)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

daInvData is a SQLDataAdapter.

The code executes without error - no exceptions. But the
data does not change. Anyone have any idea why the data does not
change, or at least why I am not getting an error message?


J
 
I don't know this message, but are your sure that dtPersonInfo has (still)
changes at the moment from updating?

Cor

dsInvestigation.dtPersonInfo
 
I checked the RowState immediately before calling Update and it says
UNCHANGED, so I guess that is my problem.

I opened the form, changed some data, then pressed the Save button
which calls the event handler, which now looks like this:

Try

MsgBox(dsInvestigation.dtPersonInfo.Item(0).RowState.ToString)
daInvData.Update(dsInvestigation, "dtPersonInfo")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

But the RowState says UNCHANGED and no updates are applied to the
source. Any ideas why it thinks that the data is unchanged when it
has clearly changed?
 
This is more of a DataBinding/WinForms thing, but you'll need to make sure
the binding completes (e.g. BindingSource.EndEdit()) before the changes are
propogated to the DataSet.

Thanks,

Shawn Wildermuth
Microsoft MVP (C#)
http://wildermuthconsulting.com
mailto:swildermuth@REMOVE_ALLCAPS_adoguy.com
 
Joe,

Why not simple tempory change an item direct before your update to try to
see what is hapening

Cor

"Joe" <[email protected]> schreef in bericht
I checked the RowState immediately before calling Update and it says
UNCHANGED, so I guess that is my problem.

I opened the form, changed some data, then pressed the Save button
which calls the event handler, which now looks like this:

Try

MsgBox(dsInvestigation.dtPersonInfo.Item(0).RowState.ToString)
daInvData.Update(dsInvestigation, "dtPersonInfo")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

But the RowState says UNCHANGED and no updates are applied to the
source. Any ideas why it thinks that the data is unchanged when it
has clearly changed?
 
Back
Top