Sqlite exceptions

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jota
Posts: 34
Joined: Tue 22 Nov 2011 19:21

Sqlite exceptions

Post by jota » Thu 14 Mar 2013 10:31

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

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: Sqlite exceptions

Post by CristianP » Thu 14 Mar 2013 13:38

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sqlite exceptions

Post by AlexP » Thu 14 Mar 2013 13:50

Hello,

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

jota
Posts: 34
Joined: Tue 22 Nov 2011 19:21

Re: Sqlite exceptions (in UniDAC)

Post by jota » Mon 18 Mar 2013 08:29

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Sqlite exceptions

Post by AlexP » Mon 18 Mar 2013 10:04

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.

Post Reply