Retrieve info on DBMS

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
brace
Posts: 213
Joined: Wed 14 Feb 2007 08:26

Retrieve info on DBMS

Post by brace » Tue 07 Apr 2015 07:38

In SDAX 7 TOLEDBConnetion does not exist anymore. I do not know how to port to SDAC 7 this code (that was working on SDAC 6.1.6):

Code: Select all

procedure GetDbsInfo(DbConn: TMSConnection);
var
  OLEDBConnection: TOLEDBConnection;
begin
  if dbConn.Connected then
  begin
    OLEDBConnection := _TMSConn(DbConn).FIConnection as TOLEDBConnection;
    FDbms := OLEDBConnection.DBMSName + ': ' + OLEDBConnection.DBMSVer;
    FDbProvider := OLEDBConnection.ProviderFriendlyName + ': ' + OLEDBConnection.ProviderVer;
  end;
end;
THe idea od this is to write into 2 strings the NAME and Version of the RDBMS + the version, this is an example of the data:

FDBMs = "Microsoft SQL Server: 10.50.1600"
FDbPRovider = "Microsot SQL Server Native Cliente 10.0: 10.50.1617.0"

Now in sdac 7 native client is not necessary, morever since i use SQL Server only i could hardcode "MS SQL Server". SO if i am not wrong all i need is to retrieve the Sql server version, client side i could mention SDAC version.

Please suggest.

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Retrieve info on DBMS

Post by azyk » Wed 08 Apr 2015 13:04

In SDAC 7.0.2, the TOLEDBConnection class is renamed to TMSConnection. The code you have provided should be modified as follows:

Code: Select all

procedure GetDbsInfo(DbConn: TMSConnection);
var
  OLEDBConnection: TMSSQLConnection;
begin
  if dbConn.Connected then
  begin
    OLEDBConnection := TMSSQLConnection(TDBAccessUtils.GetIConnection(DbConn));
    FDbms := OLEDBConnection.GetServerVersionFull;
    FDbProvider := OLEDBConnection.GetClientVersionFull + ': ' + OLEDBConnection.GetClientVersion;
  end;
end;
To use the TMSSQLConnection class, you have to add the MSClasses unit to the uses clause. SDAC version is stored in the SDACVersion constant.

brace
Posts: 213
Joined: Wed 14 Feb 2007 08:26

Re: Retrieve info on DBMS

Post by brace » Wed 08 Apr 2015 13:49

Thanks a lot for the solution provided!

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Re: Retrieve info on DBMS

Post by Dimon » Fri 10 Apr 2015 13:35

If any other questions come up, please contact us.

Post Reply