Page 1 of 1

Detect MSSQL client version sqlncli

PostPosted: Mon Jan 20, 2014 1:38 pm
by ebear
Hello all,

For several reasons I use for my MS-SQL database apps sqlncli version 11. Until now the maintenance/installation wasn't a big problem because only a few PC in my company where running the applications and I did the installation of the needed clients.
The problem now is that the applications are used on more PC systems and several times I even don't know the user is using the applications.
But of cause to have the applications working fine the right client is needed.

Is there any possibility to find at application start which client is installed on the PC? I like to build a routine at start-up, check the version, and in case of incorrect the application installs the right version before starting.

Coding the routine isn't a problem, I only need a possibility to check the sqlncli version installed.

Thanks a lot for your reactions,


Eric

Re: Detect MSSQL client version sqlncli

PostPosted: Mon Jan 20, 2014 2:23 pm
by dec
Hello,

A search on Google for a possible way to do it point us to the Windows Registry: we need to check if certain key exists or not, for example. But is not clear to me what exactly key we need to check, I have no experience with this kind of software and Google do not offer too much information (?).

If you need the latest version to be installed, in your place I take a look at the application installation directory and the possible application Windows Registry keys. Then I try to determine the better way to check the version. Since you requires certain version, maybe is not too complicated to check for the existance of certain file in the application installation directory.

In few words, look into one PC who have the correct version of the application. Look for a directory path, a directory that is created by this version of the application, for example:

Code: Select all
C:\Program files\SQL Native Client\10.0\


... so we can check if the above directory exists or not. If the directory exists we can consider that the application is installed. If the directory do not exists we can launch the application installer. Yes; I understand that everyhing I say is not a solution. But may can help you in some manner... ;)

Re: Detect MSSQL client version sqlncli

PostPosted: Mon Jan 20, 2014 2:38 pm
by ebear
Hello David,

Wouldn't it be possible to get info from the ODBC data Sources, which drivers are installed???? I already looked trough the register (that was the first thought I had) but it looks not really a standard way to find out which driver is installed.

I found for example the driver name in a key under:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{4898AD37-FE05-42df-92F9-E857DDFEE730}

Than the driver looks to be installed under C:\Windows\Systems32 but I don't know if this is applicable for each configuration. I looked trough several PC systems and the ODBC data Sources gives alway the right info.....

Eric

Re: Detect MSSQL client version sqlncli

PostPosted: Mon Jan 20, 2014 2:54 pm
by dec
Hello,

ebear wrote:Wouldn't it be possible to get info from the ODBC data Sources, which drivers are installed????


Probably this can be the best way. Maybe another mate with experience in databases can help here. ;)

Re: Detect MSSQL client version sqlncli

PostPosted: Mon Jan 20, 2014 3:03 pm
by ebear
David,

Thanks a lot for your help :D and lets wait if someone else comes up with an idea.

Eric

Re: Detect MSSQL client version sqlncli

PostPosted: Wed Jan 22, 2014 9:14 am
by CN_Iceman
What about this:

You can check for the existence of...
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\SQL Native Client

You could also check to see whether the file exists:
C:\WINDOWS\system32\sqlncli.dll

And using the dpayer's really good function File Properties you can obtain the versiĆ³n number of the sqlncli.dll file.

Here is the function:
Code: Select all
{NeoBook Function}
Version=5.70
Language=VBScript
Param=[%1]|Variable|absolute path to file
Param=[%2]|Variable|NB variable to receive list
{End}
NBselectedfile = publication.nbGetVar("[%1]")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set selectedfile = filesys.GetFile(NBselectedfile)
path = filesys.GetAbsolutePathName(NBselectedfile)
filecreatedate = selectedfile.DateCreated
filelastmodified = selectedfile.DateLastModified
filesize = selectedfile.Size
fileextension = filesys.GetExtensionName(path)
filetype = selectedfile.Type
fileversion = filesys.GetFileVersion(path)
finalstring = "Path: " & Chr(9) & path & chr(13) & "FileCreateDate: " & chr(9) & filecreatedate & chr(13) & "FileLastModified: " & chr(9) & filelastmodified & chr(13) & "FileSize: " & chr(9) & filesize & chr(13) & "FileExtension: " & chr(9) & fileextension & chr(13) & "FileType: " & chr(9) & filetype & chr(13) & "FileVersion: " & chr(9) & fileversion & chr(13)
publication.nbSetVar "[%2]", finalstring

Re: Detect MSSQL client version sqlncli

PostPosted: Thu Jan 23, 2014 1:13 pm
by ebear
Hello All,

Thanks a lot for your answers. Im going for the register check, then with David's npUtil action "npIsWindows64" (Thanks again David for implementing this] I find out if I have to install the x32 or x64 version of the client.

Regards,

Eric

Re: Detect MSSQL client version sqlncli

PostPosted: Thu Jan 23, 2014 1:29 pm
by dec
Well done! ;)

ebear wrote:Hello All,

Thanks a lot for your answers. Im going for the register check, then with David's npUtil action "npIsWindows64" (Thanks again David for implementing this] I find out if I have to install the x32 or x64 version of the client.

Regards,

Eric

Re: Detect MSSQL client version sqlncli

PostPosted: Thu Jan 23, 2014 1:50 pm
by ebear
:wink: