I can easily find out which client version I'm using, but how can I find out the server version?
There is a AdsMgGetInstallInfo
ace function and a corresponding stored procedure sp_mgGetInstallInfo
.
Do these require some special privileges?
I was expecting to find an TAdsConnection.开发者_开发问答ServerVersion
property, but something like that doesn't seem to exist?
I found the AdsConnection.ServerVersion only for the .NET provider, so it's probably missing in the Delphi Advantage Database wrapper.
But you might try to call the Advantage Management API function AdsMgGetInstallInfo and to the ADS_MGMT_INSTALL_INFO structure receive the aucVersionStr
member where should be the Advantage Database Server version. So it might look like this (it's the modified example from the AdsMgGetInstallInfo reference).
Please note, I haven't tested it and I hope you will have all data types and structure definitions.
uses ACE;
function GetServerVersion: string;
var
Size: UNSIGNED16;
MgmtHandle: ADSHANDLE;
ResultValue: UNSIGNED32;
InstallInfo: ADS_MGMT_INSTALL_INFO;
begin
Result := '';
ResultValue := ACE.AdsMgConnect('\\MyExample\Server', nil, nil, @MgmtHandle);
if (ResultValue <> AE_SUCCESS) then
Exit;
Size := SizeOf(ADS_MGMT_INSTALL_INFO);
ResultValue := ACE.AdsMgGetInstallInfo(MgmtHandle, @InstallInfo, @Size);
if (ResultValue <> AE_SUCCESS) then
Exit;
Result := InstallInfo.aucVersionStr;
end;
You should call "sp_mgGetInstallInfo" store procedure. Here is the Java example:
public static String getAdsVersion() throws ClassNotFoundException,
SQLException {
Connection conn = null;
try {
conn = getAdsConnection();
CallableStatement statement = conn
.prepareCall("{call sp_mgGetInstallInfo()}");
ResultSet resultSet = statement.executeQuery();
resultSet.next();
String version = resultSet.getString("Version");
return version;
} finally {
if (conn != null) {
conn.close();
}
}
}
Here is an example using the sp_mgGetInstallInfo
stored procedure method in Delphi, assuming you already have a TAdsQuery component with a valid connection available:
adsQuery.SQL.Clear();
adsQuery.SQL.Add('EXECUTE PROCEDURE sp_mgGetInstallInfo();');
adsQuery.Active := True;
versionStr := adsQuery.FieldByName('Version').AsString;
精彩评论