Re: SQLClient Exception - Retrying

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Shawn Berg (shawn_at_saeweb.com)
Date: 02/15/05


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
> >
> >
>
>



Relevant Pages

  • Re: Upgrading to FP SE 2002 on WinNT, IIS 4
    ... Shared\web server extensions\50\bin ... | From: "Shawn Williams" ... | If I disable the Friendly Error Messages and simply click on the "Upgrade ...
    (microsoft.public.frontpage.extensions.windowsnt)
  • Re: Computers losing their connection
    ... Is the server time syncing with an external time server? ... "Shawn Z" schreef in bericht ... they have to restart their computer to regain the connection ...
    (microsoft.public.windows.server.sbs)
  • Re: M Drive
    ... > Check this registry key and verify that drive M: ... > If not, correct it, and cycle the server. ... >> the exchange server in our office crashed today due to running out of ... >> shawn. ...
    (microsoft.public.exchange2000.admin)
  • Re: M Drive
    ... > Check this registry key and verify that drive M: ... > If not, correct it, and cycle the server. ... >> the exchange server in our office crashed today due to running out of ... >> shawn. ...
    (microsoft.public.exchange2000.setup.installation)
  • Re: SQLClient Exception - Retrying
    ... the server to restart. ... I would like to continually retry to execute it every 1 ... > Dim Retries As Integer = 0 ... > The problem I have with the code above is that I have duplicate code ...
    (microsoft.public.dotnet.framework.adonet)