Page 1 of 1

Sqlite exceptions

Posted: Thu 14 Mar 2013 10:31
by jota
Hi

When I try to connect an encrypted 'SQLite' database with a wrong password, the application throws an 'esqliteerror' exception and diplays the message 'invalid encryption and/or encryptionalgorithm specified'.

I define the next source code for catch exception. If i try compile, appear the error 'Undeclared identifier: 'ESQLiteError''

Code: Select all

        try
          FrmBasDat.ConexionBDSqlite.Connect;
        except
          on E: ESQLiteError do
          begin
            lAccPos := False;
            EscribirPalabraPaso.SetFocus;

            MessageBox(Application.Handle,
            pChar(CadenaLongitudFija('Error en la apertura de la b.d', 44)),
            pChar('Abrir B.D.'), MB_OK);
          end;
        end;
Wath i´m doing wrong? anyone can help me?

Thanks in advance

Re: Sqlite exceptions

Posted: Thu 14 Mar 2013 13:38
by CristianP
Hello,

I do a search and found ESQLiteError in LiteErrorUni.pas. Do you have LiteErrorUni in uses clause?
And you can try with Ctrl-Shift-A. Sometimes work.

Best Regards,
Cristian Peta

Re: Sqlite exceptions

Posted: Thu 14 Mar 2013 13:50
by AlexP
Hello,

Instead of the ESQLiteError class in UniDAC, in the Exception block, you should use the EUniError class

Re: Sqlite exceptions (in UniDAC)

Posted: Mon 18 Mar 2013 08:29
by jota
Hi

With next code, if database is encrypted with other algorithm or other key, the application display directly the message 'invalid encryption and/or encryptionalgorithm specified' and not execute except block.

Code: Select all

FrmBasDat.ConexionBDSqlite.SpecificOptions.Values['Direct'] := 'True';
FrmBasDat.ConexionBDSqlite.SpecificOptions.Values['EncryptionAlgorithm'] := 'leAES128';
FrmBasDat.ConexionBDSqlite.SpecificOptions.Values['EncryptionKey'] := 'abcd';

try
  FrmBasDat.ConexionBDSqlite.Connect;
except
  on E: EUniError do
  begin
	lAccPos := False;
	EscribirPalabraPaso.SetFocus;

	MessageBox(Application.Handle,
	pChar(CadenaLongitudFija('Error en la apertura de la b.d', 44)),
	pChar('Abrir B.D.'), MB_OK);
  end;
end;
Which may be the solution? I want to control the error in code of except block.

Best regards to both

Re: Sqlite exceptions

Posted: Mon 18 Mar 2013 10:04
by AlexP
Hello,

We have already modified this behaviour. Now, on an incorrect password or an encryption algorithm, you will be able to handle the error in your try..except module, in this case, an error with the code 26 will be generated. This modification will be available in the next UniDAC version.