Verify Database Update

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
 
K

Kathy Burke

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
 
M

Mark

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
 
C

CT

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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top