473,228 Members | 1,796 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,228 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 2313
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
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.