Re: SQLClient Exception - Retrying
From: Shawn Berg (shawn_at_saeweb.com)
Date: 02/15/05
- Next message: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Previous message: William \(Bill\) Vaughn: "Re: too much for stored procedure execution"
- In reply to: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Next in thread: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Reply: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Feb 2005 14:24:43 -0500
You are correct, but I do feel it is important to at least try a few more
times before completely giving up. It won't hurt, right? And as far as the
time goes, sometimes we get intermittent timeouts with our DB (very rare,
but it does happen) and these I would definitely like to retry and 99% of
the time they go through the second time around.
Can you give me any suggestions as to how this can be accomplished?
Shawn
"William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message
news:eNdgVM5EFHA.3732@TK2MSFTNGP14.phx.gbl...
> Ah, if the server goes down the pooled connection will be corrupted and
> cannot be reused. You'll also have to wait a lot longer than 3 seconds for
> the server to restart. If you lose the network you have most of the same
> issues. Putting an ADO operation in the Catch block is problematic--it
needs
> its own Try/Catch.
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> __________________________________
>
> "Shawn Berg" <shawn@saeweb.com> wrote in message
> news:%23Wcsq04EFHA.3636@TK2MSFTNGP09.phx.gbl...
> > Upon executing a stored procedure using the Data Access application
> > block's
> > SQLHelper class, I would like to continually retry to execute it every 1
> > second up to 3 times if an exception occurs. For example, if for some
> > reason
> > the database server is down, a timeout occurs, etc. I would like to
> > automatically retry a certain number of times before giving up. What is
> > the
> > best way to accomplish this? Below is what I envision (pseudo-code):
> >
> > Dim Retries As Integer = 0
> > Dim
> >
> > Try
> > '// execute database command here
> > SQLHelper.ExecuteNonQuery(...)
> > Catch ex AS SQLException
> > If Retries <= 3 Then
> > Sleep(1000)
> > SQLHelper.ExecuteNonQuery(...)
> > End If
> > End Try
> >
> > The problem I have with the code above is that I have duplicate code
> > (SQLHelper.ExecuteNonQuery(...)). The other problem I have, is what
> > happens
> > when an exception occurs in the Catch block?
> >
> > Any help would be greatly appreciated.
> >
> > Thanks,
> >
> > Shawn
> >
> >
>
>
- Next message: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Previous message: William \(Bill\) Vaughn: "Re: too much for stored procedure execution"
- In reply to: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Next in thread: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Reply: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|