Page 1 of 1

SQLite and Encryption

Posted: 21.11.2008, 21:59
by colboy
I found the [link="http://zeos.firmos.at/kb.php?mode=article&k=14"]knowledgebase[/link] article for using encryption in ZEOS 6.6.4, but still can't seem to get it to work. I create a new project, save it to disk, make sure the .NET Sqlite DLL is in the same directory, set the Zconnection protocol to sqlite-3 and the database property pointing to the database, and have the following code attached to a button:

Code: Select all

   zconnection1.Properties.Clear;
   ZConnection1.password:='letmein';
   ZConnection1.Properties.Add('encrypted=true');
   ZConnection1.Connect;
   ZTable1.TableName:='Lawyers';
   ZTable1.Active:=true; 
but when I run it says "SQL Error: file is encrypted or is not a database"

Does anybody have an idea what I am doing wrong? The knowledgebase article mentions about setting the Parameter to 'encrypted=true' however I can find no Parameter property, the nearest thing is Properties. I also notice in the knowledgebase article it mentions about manually running the .Key method, but how do I get to it?

Many thanks in advance. Colin.

Posted: 24.11.2008, 22:21
by colboy
Does no body have any pointers? I know all the supporting stuff is there, I just can't work out how to access it. Colin

Posted: 24.11.2008, 22:43
by mdaems
Does the dll you use support encryption in the first place, or is it the standard sqlite dll, which doesn't have these encryption facilities?

Mark

Posted: 24.11.2008, 22:53
by colboy
Yes, I have the required DLL as outlined in the Knowledge base. I'm assuming that .KEY method is called when the database is opened, but that doesn't appear to be the case and I can't work out how to call it myself. Colin

Posted: 25.11.2008, 08:43
by mdaems
Can you debug the TZSQLiteConnection.Open procedure in ZDbcSQLite.pas?

There you should find out if the FPlainDriver.Key call is done or not. If not : why? If yes : was it executed successfully?

Mark

Posted: 03.12.2008, 00:40
by colboy
Thanks for your help, I found the issue. During development I had the database open in SQLiteExpert, which prevented my program from opening it. Must be something to do with the encryption, as I've had the same database open in several different pieces of software before.

Colin