Delphi connection to Sqlite with Zeos

Posted by Rahman M On Friday, August 10, 2012 6 comments
http://rahsoft.blogspot.com
There are many Delphi components that can be used to interact with sqlite, one of the most popular is the ZEOS. It can be used for sqlite, ZEOS also be used to interact with some of the big servers like Oracle, MySQL, PostgreSQL and many more.

download first sqlite3.dll here and place it on the main project folder.







you can download the latest version of ZEOS here.
I assume you've installed ZEOS in delphi. here I am using Delphi 2009.
Now open your Delphi and create a new project and add components ZEOS,
TZConnection and TZQuery like this picture below. 

http://rahsoft.blogspot.com
 

 






double-click on the event onActivate Form1 and insert the following code.

procedure TForm1.FormActivate(Sender: TObject);
begin
ZConnection1.Protocol:='sqlite-3';
ZConnection1.Database:=ExtractFilePath(Application.ExeName) + '\coba.sdb';
ZConnection1.Connect;

//check connection
if ZConnection1.Connected=true then
begin
  Application.MessageBox('connection successfully done','Checking connection',MB_ICONINFORMATION);
end
else
  Application.MessageBox('connection failed','Checking connection',MB_ICONSTOP);
end; 

do compile and see if we write code that worked?
yes, it should work like the image below.

http://rahsoft.blogspot.com










in the next post we will add the data and view data in sqlite using the DBGrid. 

6 comments:

Никола Бъчваров said...
This comment has been removed by the author.
Никола Бъчваров said...

Thank you! It works - I tried with my Delphi7.

Anonymous said...

Delphi 2009 it works

AaEzha - Tutorial Internet dan Komputer said...

Ditunggu artikel selanjutnya :)

Anonymous said...

Not at all helpful.

You have a query which you do not use. What does this do apart from connect to a database?

Fajar Priyadi said...

Terimakasih Banyak

Post a Comment