Re: How to rebuild SQL connection

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Here There,

I think neilphan's suggestion on use a Try-catch block to protect the
SqlConnection establishing code is reasonable.... You can use a limited
loop to try connecting that server for several times before you abort ....
Also, you can also set the SqlConnection.ConnectionTimeout value which
controls when to abort a connecting operation after certain period of time
(default is 15 seconds....).

Hope also helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "neilphan@xxxxxxxxx" <neilphan@xxxxxxxxx>
| Newsgroups: microsoft.public.dotnet.languages.vb
| Subject: Re: How to rebuild SQL connection
| Date: 14 Dec 2005 10:36:10 -0800
| Organization: http://groups.google.com
| Lines: 30
| Message-ID: <1134585369.938469.321410@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
| References: <ezpX7ONAGHA.2736@xxxxxxxxxxxxxxxxxxxx>
| NNTP-Posting-Host: 63.167.91.4
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1134585375 32131 127.0.0.1 (14 Dec 2005
18:36:15 GMT)
| X-Complaints-To: groups-abuse@xxxxxxxxxx
| NNTP-Posting-Date: Wed, 14 Dec 2005 18:36:15 +0000 (UTC)
| In-Reply-To: <ezpX7ONAGHA.2736@xxxxxxxxxxxxxxxxxxxx>
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.7.5) Gecko/20041107 Firefox/1.0,gzip(gfe),gzip(gfe)
| Complaints-To: groups-abuse@xxxxxxxxxx
| Injection-Info: f14g2000cwb.googlegroups.com; posting-host=63.167.91.4;
| posting-account=9gVWQg0AAADsna_lET2GvPX35gp9RFRp
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.gigan
ews.com!postnews.google.com!f14g2000cwb.googlegroups.com!not-for-mail
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.vb:308674
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| You might go about creating a TRY-CATCH BLOCK inside a WHILE LOOP as in
| the code snipplet below:
|
|
----------------------------------------------------------------------------
---------------------------------------
|
| private sub MonitorDB()
|
| dim hasError as boolean = false
|
| while hasError = true
|
| try
| Dim con as SQLConnection = ....
| con.open
| ---DO WHAT EVER YOU WANT HERE----
| hasError = false
|
| catch
| hasError = true
|
| end try
|
| end while
|
| end sub
|
|
----------------------------------------------------------------------------
---------------------------------------
|
| Hope this helps.
|
|

.



Relevant Pages

  • Re: Mac Trojan
    ... before connecting to malevolent links. ... The Malicious site causes a loop to start that is difficult to exit. ...
    (comp.sys.mac.system)
  • Re: Antenna Replacement Experiment
    ... There may be different rules for connecting external antennas depending on ... if the objective is to get max gain or to get strongest null response. ... If the objective of the loop is to null out a specific frequency, ... I hope you try this antenna modification and report the results ...
    (rec.radio.amateur.antenna)
  • Re: Connect to access database
    ... never user On Error Resume Next in my scripts, so there is no worry there ... So its either not connecting or my logic is screwed up. ... you are selecting all records from the INVENTORY table. ... A Do Loop (with a "oRS.MoveNext"! ...
    (microsoft.public.scripting.wsh)
  • Re: DOS MODE command patch for CTTY w/o CTS / DSR ?
    ... You are connecting two computers together, ... "RS232 null modem with loop back handshaking" here: ... and more "RS232 null modem with loop back handshaking" here: ...
    (comp.os.msdos.djgpp)