I have downloaded wxsqlite3.4.2.0 and is facing the following problems:
1. I am unable to access database created in the earlier version (3.3.5.0) even if the database is not encrypted (i.e. password = '').
My code (lazarus freepascal, with zeolib database component) is as follows:
ZConnection1.Disconnect;
ZConnection1.Database := FileNameEdit1.FileName;
ZConnection1.Password := '';
// ZConnection1.ExecuteDirect(SELECT wxsqlite3_config("cipher", "aes256cbc"); //commented for non encryted db
ZConnection1.Connect;
Error message:
2. I can change the password of a database (created with wxsqlite3.4.2.0) with the following code:-
ZConnection1.Disconnect;
ZConnection1.Password := tx1Pass.Text; //existing password
ZConnection1.Connect;
if ZConnection1.Connected then
begin
zConnection1.ExecuteDirect('PRAGMA rekey =' + QuotedStr(tx2Pass.Text) + ';'); //only works if tx2pass.text is not blank
ZConnection1.Commit;
Showmessage('Password changed to: ' + #13 + tx2Pass.Text);
end
else
Showmessage('Unable to change key because database is not connected');
However, if I changed the password to '' (blank) then I won't be able to open tables in the database. The following error message will be displayed:
All the above codes work fine when I use wxsqlite3.3.5.0. Also, there are no problem the database is created with password using wxsqlite3.4.2.0.
Please help. Thank you.
Need help on wxsqlite3.4.2.0 Topic is solved
Re: Need help on wxsqlite3.4.2.0
After numerous time of try and error, I think I have found the solution: I have to set the encrypted property of the zConnection to true for version 3.4.2.0 as follows:
ZConnection1.Disconnect;
ZConnection1.Database := FileNameEdit1.FileName;
ZConnection1.Password := edit1.Text';
// change the encrypted parameter -- required for wxsqlite3.4.2.0
if ZConnection1.Password > '' then
ZConnection1.Properties.Values['encrypted']:= 'True'
else
ZConnection1.Properties.Values['encrypted']:= '' ;
ZConnection1.Connect;
The same is applicable to my 2nd question on changing of password rekey
ZConnection1.Disconnect;
ZConnection1.Database := FileNameEdit1.FileName;
ZConnection1.Password := edit1.Text';
// change the encrypted parameter -- required for wxsqlite3.4.2.0
if ZConnection1.Password > '' then
ZConnection1.Properties.Values['encrypted']:= 'True'
else
ZConnection1.Properties.Values['encrypted']:= '' ;
ZConnection1.Connect;
The same is applicable to my 2nd question on changing of password rekey
Re: Need help on wxsqlite3.4.2.0
This question has been answered in this post.kjteng wrote:I have downloaded wxsqlite3.4.2.0 and is facing the following problems:
1. I am unable to access database created in the earlier version (3.3.5.0) even if the database is not encrypted (i.e. password = '').
My code (lazarus freepascal, with zeolib database component) is as follows:
ZConnection1.Disconnect;
ZConnection1.Database := FileNameEdit1.FileName;
ZConnection1.Password := '';
// ZConnection1.ExecuteDirect(SELECT wxsqlite3_config("cipher", "aes256cbc"); //commented for non encryted db
ZConnection1.Connect;
As you found out yourself you have to set the password and the encrypted property of the connection object. Otherwise the database can't be established properly and executing the pragma fails.kjteng wrote: 2. I can change the password of a database (created with wxsqlite3.4.2.0) with the following code:-
ZConnection1.Disconnect;
ZConnection1.Password := tx1Pass.Text; //existing password
ZConnection1.Connect;
if ZConnection1.Connected then
begin
zConnection1.ExecuteDirect('PRAGMA rekey =' + QuotedStr(tx2Pass.Text) + ';'); //only works if tx2pass.text is not blank
ZConnection1.Commit;
Showmessage('Password changed to: ' + #13 + tx2Pass.Text);
end
else
Showmessage('Unable to change key because database is not connected');
Well, if the encrypted database was successfully opened, then using pragma rekey with a blank password should decrypt the database. So, the first step is to verify that the database was successfully opened and can be accessed.kjteng wrote: However, if I changed the password to '' (blank) then I won't be able to open tables in the database. The following error message will be displayed:
Regards,
Ulrich
Re: Need help on wxsqlite3.4.2.0
Thanks for you reply.