I am using encryption for my Sq-lite DB in Delphi 10.2 I can encrypt the database and access it setting the password in connection parameters - fine. I can decrypt it and access it when connection parameters password is blank. Fine.
The problem is that I want to use a single program to access the DB whether it is encrypted or not. If the DB is UNEncrypted, but a password is in the connection parameters, I get an error message the database "is not encrypted". Trying to set the password blank or remove it "on the fly", how can I detect the unencrypted state in time to remove the password?
I tried:
procedure TDataApp10.ConnectAppError(ASender, AInitiator: TObject;
var AException: Exception);
begin
ConnectApp.Connected:= False;
//handle most likely connect error, DB NOT encryped!
FDSQLITESecurity1.Database:= 'C:\VCDat\VCDataApp.sdb';
FDSQLITESecurity1.Password:= 'MyPW';
FDSQLITESecurity1.RemovePassword; //HANGS MESSAGE HERE!!!
ConnectApp.Params.Password:='';
ConnectApp.Connected:= True; //retry or on demand
end;
The hangup message is CIPHER: DB not encrypted