473,327 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Check for existence of server

Is there any sort of check that can be done to see if a particular instance
of SQL Server is present? I already call a method to check for connection --
if no connection, I have the user re-enter server settings (server name and
database name). But the connection check is made by calling for a scalar
value in the database. What I'd rather do is graduate the error messages:

1. No server installed
2. Specified database name not installed
3. Specfied table or sproc not available

Any thoughts?
Jan 3 '07 #1
2 2317
Earl
1) if not exists (select * from sysservers where svrname ='blblb')
print 'Server does not exist'

2) if not exists (select * from sysdatabases where name ='blblb')
print Database does not exist'

3) if object_id('test') is null
print 'An object does not exist'

"Earl" <br******@newsgroups.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Is there any sort of check that can be done to see if a particular
instance of SQL Server is present? I already call a method to check for
connection -- if no connection, I have the user re-enter server settings
(server name and database name). But the connection check is made by
calling for a scalar value in the database. What I'd rather do is graduate
the error messages:

1. No server installed
2. Specified database name not installed
3. Specfied table or sproc not available

Any thoughts?

Jan 3 '07 #2
Sure as shown on page 565, you can use the dbProviderFactories.GetFactory
method to return a list of (visible) servers based on a specific provider.
These same classes can be used to start, stop or pause the server service as
well (in addition to others).

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Earl" <br******@newsgroups.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Is there any sort of check that can be done to see if a particular
instance of SQL Server is present? I already call a method to check for
connection -- if no connection, I have the user re-enter server settings
(server name and database name). But the connection check is made by
calling for a scalar value in the database. What I'd rather do is graduate
the error messages:

1. No server installed
2. Specified database name not installed
3. Specfied table or sproc not available

Any thoughts?

Jan 3 '07 #3

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

Similar topics

3
by: Jane | last post by:
Hello, I am developing a windows service application that checks if a particular web page is on the web server. I found there is a method called File.exists(path) to check it, but how can I get...
4
by: Christopher Nelson | last post by:
I have a multi-page site that I want to be able to resume at the same page if the user leaves and comes back later (say, days later). I'm thinking that I'll set a cookie as each page is displayed...
12
by: DC Gringo | last post by:
How do I test for existence of a file in the file system: If FileExists(myVariable & ".pdf") = True pnlMyPanel.Visible = True End If -- _____ DC G
2
by: www.MessageMazes.com | last post by:
Greetings, I'm experimenting with an ASP page that reads data from a file name that is passed to it as a parameter, as in this page, which works, because the "good" file exists. ...
5
by: Gary Wessle | last post by:
hi or is there a better way to check the existence of "py" in a string "s"? string s = "djrfpyfd"; string t = "py"; string r = s.substr(s.find("py"),2); cout << (t==r) << endl;
25
by: pamelafluente | last post by:
Hi Guys, I have the following HTML code which is doing a GET to a page, say MyUrl.aspx : <body> <form name="form1" method="get" action="MyUrl.aspx" id="form1"> <input type="hidden"...
10
by: Dieter Pelz | last post by:
Hallo, what is the best way to check the installation of mfc80 and vcrt sidebyside assemblies? Best Regards, Dieter Pelz
3
by: trint | last post by:
How can I do this with my c# code with my website(because the file is there, but the code doesn't return it)?: if(File.Exists(String.Format("~/images/categories/{0}", sFileName)) return...
2
by: DesCF | last post by:
I have a textbox and a combobox on a toolstrip. The user enters either an ID in the textbox or selects a name from the combobox. When the user selects a name from the combobox the textbox is...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.