473,573 Members | 4,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sql Server Database Status

Hi all,

I'm writing some code for disaster recovery. I need to have an application
which accesses Sql Server to determine if the local database is up or not
and then if not go to the secondary server.

So like this:

1. Determine if Sql Server A is up, if so is the database active.
2. If no on either count, go to Sql Server B/database.

Is there some way to query Sql Server through the Dot Net framework to
determine the server/database status?

Thank in advance,

Bill
Nov 20 '05 #1
1 2505
Hi BIll,

Here's what I do. The key is an sproc I've created called testdatabase.
Here is its code:
CREATE PROCEDURE testdatabase AS
select databasepropert yex('imc','stat us')
where 'imc' is the name of the server to check. The code returns a string,
which I then report in the statusbar of my app, as follows:
Dim oconn As New SqlConnection(g lobalconnection string)

oconn.Open()

Dim ocmd As New SqlCommand

ocmd = New SqlCommand("exe c testdatabase", oconn)

Dim statusstring As String

Try

statusstring = ocmd.ExecuteSca lar()

Catch ex As Exception

MessageBox.Show (ex.Message)

End Try

oconn.Close()

If statusstring = "ONLINE" Then

StatusBar1.Pane ls(6).Text = "Database Online"

Me.ErrorProvide r1.SetError(Sta tusBar1, "")

ElseIf statusstring = "OFFLINE" Then

StatusBar1.Pane ls(6).Text = "Database Offline"

Me.ErrorProvide r1.SetIconAlign ment(StatusBar1 , ErrorIconAlignm ent.TopLeft)

Me.ErrorProvide r1.SetError(Sta tusBar1, "Database Offline")

ElseIf statusstring = "RESTORING" Then

StatusBar1.Pane ls(6).Text = "Database Restoring"

Me.ErrorProvide r1.SetIconAlign ment(StatusBar1 , ErrorIconAlignm ent.TopLeft)

Me.ErrorProvide r1.SetError(Sta tusBar1, "Database Restoring")

ElseIf statusstring = "RECOVERING " Then

StatusBar1.Pane ls(6).Text = "Database Recovering"

Me.ErrorProvide r1.SetIconAlign ment(StatusBar1 , ErrorIconAlignm ent.TopLeft)

Me.ErrorProvide r1.SetError(Sta tusBar1, "Database Recovering")

ElseIf statusstring = "SUSPECT" Then

StatusBar1.Pane ls(6).Text = "Database Suspect"

Me.ErrorProvide r1.SetIconAlign ment(StatusBar1 , ErrorIconAlignm ent.TopLeft)

Me.ErrorProvide r1.SetError(Sta tusBar1, "Database Malfunctioning - Call
Cherwell Immediately")

End If

HTH,

Bernie Yaeger

"William Oliveri" <wu**@bigvalley .net> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi all,

I'm writing some code for disaster recovery. I need to have an application which accesses Sql Server to determine if the local database is up or not and then if not go to the secondary server.

So like this:

1. Determine if Sql Server A is up, if so is the database active.
2. If no on either count, go to Sql Server B/database.

Is there some way to query Sql Server through the Dot Net framework to
determine the server/database status?

Thank in advance,

Bill

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
6700
by: Michele | last post by:
Hi all, I have developed a PHP-based website where a "planner" user can make up schedules of activities to be performed, storing them into MySQL tables. Afterwards, other "watcher" users can connect to the website and retrieve closest task due time, and keep retrieving next task after each one has been performed. The problem arises if the...
3
9095
by: markydev | last post by:
Hi, I'm using sql server 2000 sp4. I've 2 databases linked, an instance and my local. I'm getting two different errors when trying to update the remote table (local server) from the instance. There is only one row of data in the table with an identity field. 1st sql:- UPDATE ..dbo.NUMBERS SET =3
4
6568
by: Prince Kumar | last post by:
I joined a company recently and they have a java program which hangs (does nothing) after a while. This is no way consistent. It could succeed quite a few times and can fail a few other times. There is no consistency when it fails. Could anyone here shed some light on how to debug/resolve the issue. I guess IBM looked at the issue and were...
2
3020
by: Danny J. Lesandrini | last post by:
Our orders database exists inside our firewall but we have a web site hosted on an ISP server. If we wanted to give users the ability to query the status of their order in real time, we could just export a simple subset of data to our ISP, like customer name, order ID and status. Anyone ever do this? For example, if the status changed...
2
2243
by: Kevin R | last post by:
I'm trying to get asp.net 1.1 running on my home PC. When I try creating a new ASP.NET Web Application in 'Visual Studio .NET 2003' I get the following error: "Visual Studio .NET has detected that the specified Web server is not running ASP.NET version 1.1. You will be unable to run ASP.NET Web applications or services" Thanks for any...
2
9431
by: Charles Wilt | last post by:
I have a IBM iSeries (aka AS-400) running v5r3 of OS/400 that I access via a linked server from SQL Server 2000. The following select works fine: select * from prod400db.test.meldbf.InventoryHistory However, this insert statement fails: insert into prod400db.TEST.MELDBF.InventoryHistory
10
16196
by: sara | last post by:
Hi All, I was able to connect to MS SQL Server 2005 on my computer but after a while I can not. When I want to connect to it using MS SQL Server Management Studio I got this error: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the...
2
3221
by: Benzine | last post by:
I am running MS SQL 2000. I recently ran a procedure in Query Analyzer from the Master db to clear out all replication information so I could start/recreate it again. After I ran this procedure Enterprise Manager no longer showed the registered server in the tree. When I tried to re-register it gave me the following message:
2
21122
by: m19peters | last post by:
We have a script that I had to rework a little bit for 2005 that does a full backup for every database on the server... For some reason on some nights the script does not backup all databases... Its like it skips over it for some reason... Output of the script below on the night in question was: Executed as user: NT AUTHORITY\SYSTEM. master...
0
7707
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8086
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6432
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5605
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5296
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3737
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2227
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1325
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1048
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.