The problem of UniDac implementing SQLite database through multiple third-party encryption connections via TUNiconnect.

The problem of UniDac implementing SQLite database through multiple third-party encryption connections via TUNiconnect.


I am building a Delphi application that can connect to SQLite databases,
But because there are multiple DLL implementations for encrypting SQLite databases,
At the same time, the encrypted SQLite database cannot know the type of encryption,
So I created a function to traverse connections,
Until success.

The problem I am facing now is that when I pass
SpecificOptions.Values['ClientLibrary']:=ExtractFilePath(Application.ExeName) + 'SQLite.Interop.dll';

If the connection fails, proceed to the next connection, but in reality. Changing this parameter will not be of any use.
You will receive the following prompt:


Here is my link source code. I hope to receive some guidance. Thank you.

  1. function TFormConnectPOS.SQLiteLink: boolean;
  2. type
  3.   TEncryptionScheme = record
  4.     SchemeName: string;
  5.     ClientLibrary: string;
  6.     EncryptionKey: string;
  7.     Direct: string;
  8.   end;
  9. var
  10.   strTmp: string;
  11.   I: Integer;
  12.   Schemes: array of TEncryptionScheme;
  13.   Scheme: TEncryptionScheme;
  14.   ErrMsg: string;

  15.   function TryConnectWithScheme(AUniConnection: TUniConnection; const AScheme: TEncryptionScheme; const DatabasePath: string; var AErrMsg: string): Boolean;
  16.   begin
  17.     Result := False;
  18.     try

  19.       AUniConnection.Server := '';
  20.       AUniConnection.Database := edtDBServer.Text + '\' + edtDBName.Text;

  21.       AUniConnection.Password := edtDBPWD.Text;

  22.       AUniConnection.Username := edtDBUID.Text;

  23.       AUniConnection.ProviderName := DMGoodsImport.recordDBSelectSQLes.strproviderName;

  24.       AUniConnection.SpecificOptions.Values['UseUnicode'] := 'True';

  25.       AUniConnection.SpecificOptions.Values['ASCIIDataBase'] := 'False';

  26.       AUniConnection.Database := DatabasePath;


  27.       AUniConnection.Connected := False;
  28.       AUniConnection.Connected := True;

  29.       Result := AUniConnection.Connected;
  30.     except
  31.       on E: Exception do
  32.       begin
  33.         AErrMsg := E.Message;
  34.       end;
  35.     end;
  36.   end;

  37. begin

  38.   bPosConnectedResult := False;

  39.   DMGoodsImport.UniConPOS.Server := '';
  40.   DMGoodsImport.UniConPOS.Database := edtDBServer.Text + '\' + edtDBName.Text;

  41.   DMGoodsImport.UniConPOS.Password := edtDBPWD.Text;

  42.   DMGoodsImport.UniConPOS.Username := edtDBUID.Text; 

  43.   DMGoodsImport.UniConPOS.ProviderName := DMGoodsImport.recordDBSelectSQLes.strproviderName;

  44.   //----------------------------------------------------------------------------


  45.   SetLength(Schemes, 3);


  46.   Schemes[0].SchemeName := 'Default';
  47.   Schemes[0].ClientLibrary := '';
  48.   Schemes[0].EncryptionKey := '';
  49.   Schemes[0].Direct := 'True';


  50.   Schemes[1].SchemeName := 'SQLite3.dll';
  51.   Schemes[1].ClientLibrary := ExtractFilePath(Application.ExeName) + 'sqlite3.dll';
  52.   Schemes[1].EncryptionKey := edtDBPWD.Text;
  53.   Schemes[1].Direct := 'False';


  54.   Schemes[2].SchemeName := 'SQLite.Interop.dll';
  55.   Schemes[2].ClientLibrary := ExtractFilePath(Application.ExeName) + 'SQLite.Interop.dll';
  56.   Schemes[2].EncryptionKey := edtDBPWD.Text;
  57.   Schemes[2].Direct := 'False';

  58.   //----------------------------------------------------------------------------

  59.   if FileExists(DMGoodsImport.UniConPOS.Database) then
  60.   begin

  61.     for I := 0 to High(Schemes) do
  62.     begin
  63.       Scheme := Schemes[I];

  64.       if TryConnectWithScheme(DMGoodsImport.UniConPOS, Scheme, DMGoodsImport.UniConPOS.Database, ErrMsg) then
  65.       begin

  66.         Result := True;
  67.         bPosConnectedResult := True;


  68.         break;
  69.       end;
  70.     end;

  71.   end;

  72.   end;