Re: How to roll back transactions in Try Catch loops?
From: William F. Robertson, Jr. (theman_at_nameht.org)
Date: 01/28/05
- Next message: Matt Berther: "Re: Response.WriteFile help please"
- Previous message: Jeff Robichaud: "Re: Having ASPNET member of Administrators"
- In reply to: JenHu: "How to roll back transactions in Try Catch loops?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 28 Jan 2005 15:14:30 -0600
When are you assigning your variable trans?
try
trans = connection.BeginTransaction()
'run queries
catch
if NOT trans = null then
trans.RollBack()
endif
bill
"JenHu" <jenniferhu46@hotmail-dot-com.no-spam.invalid> wrote in message
news:41faa73c_1@127.0.0.1...
> Hi experts,
>
> I want to rollback the insert/update in my SQL Server database
> tables if there's any errors, and I use trans.Rollback(). However,
> whenever error generates, the rollback doesn't work at all, and it
> throws this server error:
>
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of
> the current web request. Please review the stack trace for more
> information about the error and where it originated in the code.
>
> Exception Details: System.NullReferenceException: Object reference not
> set to an instance of an object.
>
> can anyone tell me what does this go wrong? Thanks.
> ------------------------------------------------------
>
> Dim trans As System.Data.SqlClient.SqlTransaction
> Try
> .........some codes...........
>
> Catch exp As Exception
>
> 'rollback the transaction if any step above is not successful
> trans.Rollback()
>
> End Try
> *---------------------------------*
> Posted at: http://www.GroupSrv.com
> Check: http://wwww.HotCodecs.com
> *---------------------------------*
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com
- Next message: Matt Berther: "Re: Response.WriteFile help please"
- Previous message: Jeff Robichaud: "Re: Having ASPNET member of Administrators"
- In reply to: JenHu: "How to roll back transactions in Try Catch loops?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|