* * *

Author Topic: sqlite  (Read 1208 times)

moessner

  • New member
  • *
  • Posts: 5
sqlite
« on: April 16, 2017, 03:50:26 pm »
I wish thank you for the interesting.

I have this problem : I try to connect a database with a sqlconnector or a sqlite3connection but when I active the connection and the sqlquery don't connect the dataset.

The error is : no such table for the component connection.

I wish specify that I have also a component sqltransaction on the form and a datasource.

Thank to all wish to help me.

moessner

valdir.marcos

  • Full Member
  • ***
  • Posts: 240
Re: sqlite
« Reply #1 on: April 16, 2017, 04:34:36 pm »
Are you using the latest Lazarus 1.6.4 and FPC 3.0.2?

Have you read ?
http://wiki.freepascal.org/SQLdb_Tutorial1
http://forum.lazarus.freepascal.org/index.php?topic=16852.0
http://wiki.freepascal.org/SQLite
https://www.sqlite.org/docs.html

Zip a small test project (without binary) and attach to this thread, so we can easily understand what is happening.

moessner

  • New member
  • *
  • Posts: 5
Re: sqlite
« Reply #2 on: April 16, 2017, 06:11:34 pm »
Thank for helping.

I use lazarus 1.6.4. .

I have a dbgrid connected to a normal dataset connected to sqllite3conncection connected to sqltransaction.

i try to active all the components in this mode:


procedure TForm1.FormActivate(Sender: TObject);
begin
  sqlquery1.active := true ;
  Sqlite3Connection1.databasename := "c:\db\Nuovo_DB.DB" ;
  Sqlite3Connection1.connected := true ;
  Sqltransaction1.active := true ;
end;   

Many thanks

moessner


Thaddy

  • Hero Member
  • *****
  • Posts: 4251
Re: sqlite
« Reply #3 on: April 16, 2017, 06:50:05 pm »
You set things "active" (not just database components) when you have completed the setup of things and they need to start some kind of job....
Now. Change your workflow order and see if it helps...
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

valdir.marcos

  • Full Member
  • ***
  • Posts: 240
Re: sqlite
« Reply #4 on: April 16, 2017, 11:23:01 pm »
You set things "active" (not just database components) when you have completed the setup of things and they need to start some kind of job....
Now. Change your workflow order and see if it helps...

procedure TForm1.FormActivate(Sender: TObject);
begin
  sqlquery1.active := true ;
  Sqlite3Connection1.databasename := "c:\db\Nuovo_DB.DB" ;
  Sqlite3Connection1.connected := true ;
  Sqltransaction1.active := true ;
end;   

As Thaddy said, be careful with component sequence of activation.
Be also careful with the differences among the events FormCreate and FormActivate:
https://www.thoughtco.com/life-cycle-of-a-delphi-form-1058011
http://www.askingbox.com/info/delphi-event-order-of-a-form-from-oncreate-to-ondestroy

Code: Pascal  [Select]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   SQLite3Connection1.DatabaseName := "c:\db\Nuovo_DB.db" ;
  4.   SQLite3Connection1.Connected := True ;
  5.  
  6.   SQLTransaction1.Database := SQLite3Connection1;
  7.   SQLTransaction1.Active := True ;
  8.  
  9.   SQLQuery1.Database := SQLite3Connection1;
  10.   SQLQuery1.Transaction :=  SQLTransaction1;
  11.   SQLQuery1.SQL.Text := 'Select * From TableName Order By FieldName1';
  12.   SQLQuery1.Active := true ;
  13.  
  14.   // -> doubleclick on SQLQuery1 component
  15.   // -> click on + sign to add tablefields
  16.  
  17.   // just in case you use dbware components
  18.   DataSource1.Dataset := SQLQuery1;
  19.  
  20.   DBEdit1.DataSource := DataSource1;
  21.   DBEdit1.DataField := 'FieldTestName';
  22. end;  
  23.  

moessner

  • New member
  • *
  • Posts: 5
Re: sqlite
« Reply #5 on: April 17, 2017, 12:33:02 am »
I wish thank you for the answer.

But i don't understand  what is tablename.

It seems a Alias but where i can set it up

Thank you   

valdir.marcos

  • Full Member
  • ***
  • Posts: 240
Re: sqlite
« Reply #6 on: April 17, 2017, 01:18:08 am »
I don't know the structure of your tables on "c:\db\Nuovo_DB.DB", so I used "TableName" and FieldName1" just as a way to indicating for your where you would put the name for your table and the names of the fields to ordinate your query.

Just in case you are also starting on SQLite, here you can find a fast course:
https://www.tutorialspoint.com/sqlite/sqlite_select_query.htm

And here another one for Pascal:
https://www.tutorialspoint.com/pascal/index.htm

« Last Edit: April 17, 2017, 03:37:45 pm by valdir.marcos »

moessner

  • New member
  • *
  • Posts: 5
Re: sqlite
« Reply #7 on: April 17, 2017, 03:32:30 am »
Thanks a lot

Moessner

moessner

  • New member
  • *
  • Posts: 5
Re: sqlite
« Reply #8 on: April 17, 2017, 04:26:23 am »
I have open the database ! ! !

Thank you

Thank you

Thank you

Thank you

Thank you

jma_sp

  • Full Member
  • ***
  • Posts: 128
  • El conocimiento si ocupa lugar.
Re: sqlite
« Reply #9 on: April 17, 2017, 09:22:25 am »
Also, you can use lazsqlx to modify your SQLite table(s) into database easily or see existing tablenames:

https://sourceforge.net/projects/lazsqlx/?source=directory

Or with:

https://github.com/sqlitebrowser/sqlitebrowser/releases
« Last Edit: April 17, 2017, 09:25:46 am by jma_sp »
Debian 8.6 - (JWM/ROX/iDesk) - Devuan Jessie 1.0 ( without systemd ) - Puppy -  Quirky Xerus 8.2 - Windows XP - ReactOS 0.4.xx  - FreeDos - OctaOS - KolibriOS

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus