Recent

Author Topic: Can't connect to the database (Sqlite3)  (Read 459 times)

zzzzzzz7

  • New Member
  • *
  • Posts: 14
Can't connect to the database (Sqlite3)
« on: December 17, 2025, 02:50:10 pm »
I already have a zdb.db file, which also contains a table (ID, NAME, etc.).
I am using Lus and cannot connect [Sqlite3Connerctiong1   SQL Transaction1   DataSource1   SQLQuery1].
1. Sqlite3Connerction1.DatabaseName = G\pascal\zdb.db;
Sqlite3Connerctiong1.Transaction = SQLTransaction1;
SQLTransaction1. = SQLite3Connection1;
DtatSource1.Dataset = SQLQuery1;
SQLQuery1.Database = SQLite3Connerction1;
If SQLQuery1.DataSource = DataSource1; (message: circular datasource references are not allowed);

DBgGrid1.DataSource = DataSource1;
Why can't I see the table I created in zdb (ID name, etc.) in DBgGrid1?
DBgGrid1.Active --- showmessage('SQL statement not set ');

How should I set it up to connect to SQLite3 correctly and display my table in DBgGrid1

Zvoni

  • Hero Member
  • *****
  • Posts: 3219
Re: Can't connect to the database (Sqlite3)
« Reply #1 on: December 17, 2025, 03:18:50 pm »
Well, the message is clear: You have to tell the SQLQuery, which fields from which table to present.....

SQLQuery1.SQL.Text:='SELECT ID, Name FROM MyTable';
or set it in Object-Inspector
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

zzzzzzz7

  • New Member
  • *
  • Posts: 14
Re: Can't connect to the database (Sqlite3)
« Reply #2 on: December 18, 2025, 10:05:27 am »
thanks  , write select * from ...        the table show     

CharlyTango

  • Full Member
  • ***
  • Posts: 175
Re: Can't connect to the database (Sqlite3)
« Reply #3 on: December 18, 2025, 11:36:31 pm »
I assume that @zvoni wrote
'SELECT ID, Name FROM MyTable';
on purpose because SELECT * is a bad habit and will bring you more troubles than you are willing to solve on the long run.
Lazarus stable, Win32/64

 

TinyPortal © 2005-2018