You are not logged in.
Pages: 1
I get the following error compiling the code below
E2010 Incompatible types: 'TSqlDBOleDBConnectionProperties' and 'class of TSqlDBOleDBMSSQL2012ConnectionProperties'
function TMMBaseDB.GetODBCDriverSpec: TOleDBConnectionProperties;
const
ODBCDriverKey_2018 = '\SOFTWARE\ODBC\ODBCINST.INI\ODBC Driver 17 for SQL Server';
ODBCDriverKey_2012 = '\SOFTWARE\ODBC\ODBCINST.INI\SQL Server Native Client 11.0';
ODBCDriverKey_2008 = '\SOFTWARE\ODBC\ODBCINST.INI\SQL Server Native Client 10.0';
begin
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE; //2147483650;//
if OpenKeyReadOnly(ODBCDriverKey_2012) then
begin
result := TOleDBMSSQL2012ConnectionProperties;
CloseKey;
end
else if OpenKeyReadOnly(ODBCDriverKey_2008) then
begin
result := TOleDBMSSQL2008ConnectionProperties;
CloseKey;
end
else
result := TOleDBMSSQLConnectionProperties;
finally
Free;
end;
end;
I can not understand this as it is declared in unit "mormot.db.sql.oledb" like:
TSqlDBOleDBMSSQL2012ConnectionProperties = class(TSqlDBOleDBMSSQLConnectionProperties)
Hope I can get some help solving this, the code is converted from an old mormot-1 unit, and it worked there.
This is my uses clause:
uses
mormot.core.base
, mormot.orm.base
, mormot.orm.core
, mormot.rest.server
, mormot.db.sql.oledb
, mormot.orm.sql
, system.classes
, Winapi.Windows
;
Delphi-11, WIN10
Offline
Your code is mixing class instances and class types.
It did not work on mORMot 1 either, for sure: you made certainly a typo during the conversion.
Try with:
function TMMBaseDB.GetODBCDriverSpec: TSqlDBConnectionPropertiesClass;
I also don't understand why you look at ODBC entry keys, not OleDB.
Re not HKEY_CLASSES_ROOT\MSOLEDBSQL and HKEY_CLASSES_ROOT\SQLNCLI11 enough?
Offline
Thanks! I had missed a couple of units, after correcting that I could go on and now made it work.
ODBC?... well I have used this type for many years and had no idea of that key. Is there some benefits by using OleDB keys?
I'll look at this later on.
Delphi-11, WIN10
Offline
Pages: 1