Sponsors

Delphi connection to Sqlite with Zeos

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. 
                                                

Post a Comment

10 Comments

  1. Delphi 2009 it works

    ReplyDelete
  2. Not at all helpful.

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

    ReplyDelete
  3. Works for me although there was a bit of messing around with field types before I could actually see and edit some.

    Note that text = memo in Delphi and String is required to edit strings in a grid.

    ReplyDelete
  4. Jeszcze !!!Przykład otwarcia bazy i upchanie w TABELę GRID///

    ReplyDelete
  5. MconslioterfniSpringfield Jane Milligan download
    prosexuntau

    ReplyDelete