Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 6th, 2006, 06:56 PM
Authorized User
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
Default detecting SQL server down

Hi all,

I have a VB app that that runs on one PC and accesses SQL server running on another PC using ADO. I am trying to determine the best way to detect when SQL server is no longer available due to being shutdown or a network problem.
The app keeps a connection open all the time. It uses recordsets to get read and write data when needed.
I would like to detect the moment SQL server goes down so that before running a query the state of the server will be known and handled accordingly.
I found the Disconnect event and the State property in the Connection object of little use.

Thanks in advance,


Reply With Quote
  #2 (permalink)  
Old July 8th, 2006, 12:30 AM
Friend of Wrox
Join Date: May 2006
Location: Helsingborg, , Sweden.
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts

It is bad design having an open connection to the database for a long time.

Open only a connection when you really need to connect to the database. Your machine will never now anyway, if a cable is unplugged or a switch/hub break down in your network.

Reply With Quote
  #3 (permalink)  
Old August 1st, 2006, 02:28 AM
Authorized User
Join Date: Jun 2003
Location: , , Norway.
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts

Peso, isn't that what for instance SQL Management Studio does when you open a query-window against a DB? Will not that connection be held for the duration of the query-window?

best regards

Reply With Quote
  #4 (permalink)  
Old August 1st, 2006, 08:04 AM
Friend of Wrox
Join Date: May 2006
Location: Helsingborg, , Sweden.
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts

Who said that is good design for business applications?

It is better to close the connection when the call to the database is made and the work is finished.
If you are using connection pooling, the new connection when you want to to additional work, will be very fast.

This way you will now faster when the server cannot be connected. You will now in less than default 15 (I often set this to 5) seconds that the server is down. If the connection is open the whole time, you will have to rely on the CommandTimeout parameter before the error is thrown back at you, and this value can be anything from default 30 (which i often set to 300) seconds to infinity...

The Disconnect event is only thrown when manually disconnecting, not when problem with network arises.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conflict in SQL Server 2000 and SQL Server 2005 ayan.mukherjee SQL Language 0 June 30th, 2008 03:34 AM
SQL Server Reg. SQL Server does not exist error Arsi SQL Server 2000 1 June 11th, 2008 11:20 AM
migrating from sql server 2000 to sql server 2005 abinashpatra SQL Server 2005 2 December 1st, 2006 03:45 PM
SQL Server sync with net server and browser server ne SQL Server DTS 0 June 13th, 2005 06:29 PM
Diff b/w SQL Server 7 and SQL Server 2000 ashu_from_india SQL Server 2000 1 April 25th, 2005 01:00 PM

All times are GMT -4. The time now is 11:24 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.