Re: SQLClient Exception - Retrying
From: Shawn Berg (shawn_at_saeweb.com)
Date: 02/15/05
- Next message: Joe: "Re: Opening Excel worksheet missing cell values"
- Previous message: neptune3k: "How to display different data"
- In reply to: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Next in thread: Shawn Berg: "Re: SQLClient Exception - Retrying"
- Reply: Shawn Berg: "Re: SQLClient Exception - Retrying"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Feb 2005 15:10:26 -0500
This app I am programming is not operated by a live user, but more of a
service app which needs to continually run uninterrupted no matter what
network problems may be occurring. When there are network problems,
timeouts, sql server is down, etc. I need the app to handle this gracefully
and process all remaining transactions when the problems are resolved. This
has to be done without any user intervention. This is why I want to retry no
matter what the error may be, and continue to do so until the problem is
resolved.
What is the best way to code this?
"William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message
news:#nA2HS5EFHA.1836@tk2msftngp13.phx.gbl...
> With timeouts, yes it makes sense to retry. With the other failures, it's
a
> waste of time. I would add code to test the viability of the LAN and SS
> connection and retry once they are back up. In the meantime I would inform
> the user that there are problems with the server and/or back off to a
> mirrored or backup server. This will be easy with Whidbey/Yukon and the
2.0
> Framework. It can be done now, but it's a bit harder.
>
> --
> ____________________________________
> 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:eD4poO5EFHA.4072@TK2MSFTNGP10.phx.gbl...
> > 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: Joe: "Re: Opening Excel worksheet missing cell values"
- Previous message: neptune3k: "How to display different data"
- In reply to: William \(Bill\) Vaughn: "Re: SQLClient Exception - Retrying"
- Next in thread: Shawn Berg: "Re: SQLClient Exception - Retrying"
- Reply: Shawn Berg: "Re: SQLClient Exception - Retrying"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|