1

My intention is to use the new Microsoft OLE DB Driver for SQL Server (msoledbsql) for database connection in Delphi 5 if it is installed in the system. If it is not installed than I am using old driver (sqloledb). My question is: What would be the proper way to check for the driver installed in the system? I guess it has somethink to do with Registry check and also some dlls existing in the folder. I know how to chek for dlls but I am not sure about the Registry.

pyfyc
  • 127
  • 2
  • 9
  • Note that MSOLEDBSQL (and SQLNCLI11) do some things differently than sqloledb. We had some issues where it calls sp_describe_first_result_set instead of the deprecated SET FMTONLY ON method to get result column structures. When used with some insert queries that used select SCOPE_IDENTITY() as part of the same statement (using `qry.Open()` instead of `qry.ExecSQL` it failed on some tables with complex triggers. – Gerry Coll Aug 08 '18 at 03:43

1 Answers1

2

You can use ADODB.GetProviderNames()

This will populate a TStrings with a list of all installed providers. I assume it was added when ADODB.pas was first created for Delphi 5 in 1999, but I have no way to confirm that.

Here's one I prepared earlier...

Providers := TStringList.Create;
try
  GetProviderNames(Providers);
  if Providers.IndexOf('MSOLEDBSQL') >= 0 then
    ConnectionString := 'Provider=MSOLEDBSQL.1;'
  else
    ConnectionString := 'Provider=SQLNCLI11.1;';
finally
  Providers.Free;
end;

if it isn't, look at Check if Microsoft OLE DB Provider for Index Server (aka Provider=MSIDXS) is installed? for a C# example. It is fairly simple COM handling

Gerry Coll
  • 5,867
  • 1
  • 27
  • 36