473,888 Members | 1,378 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 2536
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
6719
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 planner asynchronously changes the schedule, e.g. deleting the task "watcher" users consider to be...
3
9108
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
6604
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 not able to pinpoint where the issue is. When the program hangs and when force the DB2...
2
3047
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 from REQUEST to QUOTE or from QUOTE to PRODUCTION, the AfterUpdate event of the Access application...
2
2297
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 help in advance. Kevin ===============================
2
9492
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
16226
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 default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider,...
2
3238
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
21143
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 (Message 0) Status is ONLINE dbname / dbdevice = master / SQLBUmaster (Message 0) Processed...
0
9961
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9800
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11185
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10439
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7990
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3252
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.