Verify Database Update

  • Thread starter Thread starter Kathy Burke
  • Start date Start date
K

Kathy Burke

Hi, I asked this question last week, but still need some help.

When I do an update to a database record (SQL Server), how would I do
the code to verify that the update event has happened? I can't use
transactions or stored procs in SQL Server. Is there a way to use vb in
the asp.net sub procedure that would do this?

Thanks.

Kathy
 
Since I'm only updating one record, it sounds good!

I've never used it, could you possibly shoot me a code example of how to
use it?

Thanks!

Kathy
 
If you use an instance of the SqlCommand class with the ExecuteNonQuery
method, it will return the number of rows affected by the SQL or Stored Proc
that executed. That would be good enough for me ... I suppose you could
also simultaneously update a modified_dt column with the current time, and
then confirm that the record now has the updated time, rather than the old
time.

Hope this helps.

Mark
www.dovetaildatabases.com
 
Kathy,

Well, here's a short VB example of how to set it up:

Protected Shared Sub OnRowUpdated(ByVal sender As Object, ByVal e As
SqlRowUpdatedEventArgs)
' In this procedure you can perform checks of what happened, i.e.
' did the updated work and if not, what went wrong.
' Check the properties of the passed instance of
' SqlRowUpdatedEventArgs (e). Please see the docs for
' more information.
End Sub

......
Dim MyDataAdapter As New SqlDataAdapter(...)

' Set up event handler
AddHandler MyDataAdapter.RowUpdated AdressOf OnRowUpdated

......

Now, the RowUpdated (after) event is commonly used in connection with the
RowUpdating event (before), so do have a look at both in the docs. I hope
this gets you going.
 
Back
Top