|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Recognizing if SQL Server is installed (and what version)Hello,
I have an application which I'd like to determine if SQL Server is installed, and if so, what version. Is there any way to do this outside of error trapping? Thanks! Rick Not sure if it will work, but you could scan the registry, or even
search harddrive for the exe. It would probably be quicker to to just use error checking though. Just my 2 cents, Seth Rowe Rico wrote: Show quoteHide quote > Hello, > > I have an application which I'd like to determine if SQL Server is > installed, and if so, what version. Is there any way to do this outside of > error trapping? > > Thanks! > Rick Try to connect with a sqlconnection to (local) using integrated security
If it fails to connect, it is not installed, or the current user has no rights to connect (check error). If it is connected, you can read the version from the ServerVersion property. Rico wrote: Show quoteHide quote > Hello, > > I have an application which I'd like to determine if SQL Server is > installed, and if so, what version. Is there any way to do this outside of > error trapping? > > Thanks! > Rick > > This is probably the only "prpper" way to do this. Unfortunately, the
OP said he didn't want to do any error trapping (which I assumed meant he didn't want to try to connect to the server) - but I say "to bad!" :-) Thanks,Seth Rowe Theo Verweij wrote: Show quoteHide quote > Try to connect with a sqlconnection to (local) using integrated security > If it fails to connect, it is not installed, or the current user has no > rights to connect (check error). > If it is connected, you can read the version from the ServerVersion > property. > > Rico wrote: > > Hello, > > > > I have an application which I'd like to determine if SQL Server is > > installed, and if so, what version. Is there any way to do this outside of > > error trapping? > > > > Thanks! > > Rick > > > > I never understand the questions where the "programmer" doesn't want to
use exception handling. I always wander what such applications look like (and how they work) .... rowe_newsgroups wrote: Show quoteHide quote > This is probably the only "prpper" way to do this. Unfortunately, the > OP said he didn't want to do any error trapping (which I assumed meant > he didn't want to try to connect to the server) - but I say "to bad!" > :-) > > Thanks, > > Seth Rowe > > > Theo Verweij wrote: >> Try to connect with a sqlconnection to (local) using integrated security >> If it fails to connect, it is not installed, or the current user has no >> rights to connect (check error). >> If it is connected, you can read the version from the ServerVersion >> property. >> >> Rico wrote: >>> Hello, >>> >>> I have an application which I'd like to determine if SQL Server is >>> installed, and if so, what version. Is there any way to do this outside of >>> error trapping? >>> >>> Thanks! >>> Rick >>> >>> > The only reason is to avoid them is because try catch statements can
add a lot of overhead if used excessively. Thanks, Seth Rowe Theo Verweij wrote: Show quoteHide quote > I never understand the questions where the "programmer" doesn't want to > use exception handling. I always wander what such applications look like > (and how they work) .... > > rowe_newsgroups wrote: > > This is probably the only "prpper" way to do this. Unfortunately, the > > OP said he didn't want to do any error trapping (which I assumed meant > > he didn't want to try to connect to the server) - but I say "to bad!" > > :-) > > > > Thanks, > > > > Seth Rowe > > > > > > Theo Verweij wrote: > >> Try to connect with a sqlconnection to (local) using integrated security > >> If it fails to connect, it is not installed, or the current user has no > >> rights to connect (check error). > >> If it is connected, you can read the version from the ServerVersion > >> property. > >> > >> Rico wrote: > >>> Hello, > >>> > >>> I have an application which I'd like to determine if SQL Server is > >>> installed, and if so, what version. Is there any way to do this outside of > >>> error trapping? > >>> > >>> Thanks! > >>> Rick > >>> > >>> > > Agreed.
You only use these constructions when needed. It is better to avoid exceptions where possible, by doing the proper checks before executing the statements. But there will always be exceptions in a program that must be handled. The problem I detect in the question of Rick, is that he is using the word "Error trapping", instead of exception handling; an exception is not always an error. The problem with another way of SQL Server checking(like the registry way provided in the reply of HKSHK) is that the registry entries are changing when new versions of SQL Server are released; SQL 2000 version is stored in Microsoft SQL Server\80, SQL 2005 in Microsoft SQL Server\90, SQL 7 in Microsoft SQL Server\70, SQL 6.5 - I don't know. And maybe the next version will use a complete other path, or even no registry settings at all. Another problem is that you may know that it is installed, and what version it is, but if you don't know if it is running (or if the user has the right to connect to it) you still have to apply a try catch block to a connection to this instance. rowe_newsgroups wrote: Show quoteHide quote > The only reason is to avoid them is because try catch statements can > add a lot of overhead if used excessively. > > Thanks, > > Seth Rowe > > > Theo Verweij wrote: >> I never understand the questions where the "programmer" doesn't want to >> use exception handling. I always wander what such applications look like >> (and how they work) .... >> >> rowe_newsgroups wrote: >>> This is probably the only "prpper" way to do this. Unfortunately, the >>> OP said he didn't want to do any error trapping (which I assumed meant >>> he didn't want to try to connect to the server) - but I say "to bad!" >>> :-) >>> >>> Thanks, >>> >>> Seth Rowe >>> >>> >>> Theo Verweij wrote: >>>> Try to connect with a sqlconnection to (local) using integrated security >>>> If it fails to connect, it is not installed, or the current user has no >>>> rights to connect (check error). >>>> If it is connected, you can read the version from the ServerVersion >>>> property. >>>> >>>> Rico wrote: >>>>> Hello, >>>>> >>>>> I have an application which I'd like to determine if SQL Server is >>>>> installed, and if so, what version. Is there any way to do this outside of >>>>> error trapping? >>>>> >>>>> Thanks! >>>>> Rick >>>>> >>>>> > Dear Rick,
To check if SQL Server is installed, you can check if this registry key exists: HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\Microsoft SQL Server For the version, I'm not sure since I don't have different versions of SQL Server installed. On my computer, the registry path HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\Microsoft SQL Server\80\Tools\Client Setup\Current Version exists. In this key, you can read the string "CurrentVersion". In my case it's 8.00.194. Best Regards, HKSHK Rico napisal(a):
> Hello, Hi, i use this code to check about running instances, which can also> > I have an application which I'd like to determine if SQL Server is > installed, and if so, what version. Is there any way to do this outside of > error trapping? > > Thanks! > Rick provide information about version. I know it's not 100% what you looking for, but perhaps will be useful: Imports System.Data.Sql Public class test Private _list_inst As SqlDataSourceEnumerator Public Property list_inst() As SqlDataSourceEnumerator Get Return _list_inst End Get Set(ByVal value As SqlDataSourceEnumerator) _list_inst = value End Set End Property Private Function listservers() As DataTable list_inst = Sql.SqlDataSourceEnumerator.Instance Return list_inst.GetDataSources End Function end class Function listservers return datatable with current installed and running (!) instances. There is column called version. Greeting PK Rico,
Execute this select statement: SELECT @@VERSION Cheers, Rob Panosh Rico wrote: Show quoteHide quote > Hello, > > I have an application which I'd like to determine if SQL Server is > installed, and if so, what version. Is there any way to do this outside of > error trapping? > > Thanks! > Rick
Installed, but where is it?
Full qual. name of current method DateTime Field Writing Data In Tabular format in Text File. VBNET2005 : Manipulating MS Access tabledefinitions in VB.NET -> Create, Copy and Drop Table. Showing Form in New Thread? db connections and text boxes Passing parameters in VB 2005!! Uninstall a device Split monitor screen into multiple windows |
|||||||||||||||||||||||