Re: Recognizing if SQL Server is installed (and what version)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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:
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



.



Relevant Pages

  • Re: Delphi handling of SQL server generated errors
    ... Delphi should raise an Exception whenever a client ... >app that is connected to an SQL Server runs an SQL statment that ... whenever SQL Server rasies an error using the ...
    (comp.lang.pascal.delphi.misc)
  • Re: SQL 2005 error 17311
    ... You will need to post larger segments to see exactly what component died and took SQL out with it. ... C++ exception, or by an access violation encountered during exception ... This exception forces SQL Server to shutdown. ... Cluster resource 'SQL Server' in Resource Group 'SQL_Server' failed. ...
    (microsoft.public.sqlserver.clustering)
  • Re: Accesing fields in a datareader
    ... Is very hard for me add aliases in the fields, and the indexer is not secure ... >> when I read the values with an oledbdatareader accesing a SQL Server ... >> but result in an exception. ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Can not instantiate SqlCeRemoteDataAccess
    ... there's an error collection in SQL CE ... > We are using RDA to pull and push the data from SQl Server. ... Exception message is also blank. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Embedded SP
    ... I have error trapping in the page but am not sure if the ... Any error in SQL Server yields an exception which you can catch with ... A second option is to set the connection property ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (microsoft.public.sqlserver.programming)