Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2006, 06:56 PM
Authorized User
 
Join Date: Nov 2005
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,

George.



 
Old July 8th, 2006, 12:30 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old August 1st, 2006, 02:28 AM
Authorized User
 
Join Date: Jun 2003
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Gert

 
Old August 1st, 2006, 08:04 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






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





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