Recent

Author Topic: SQLite basic setup help  (Read 2001 times)

mrguzgog

  • Jr. Member
  • **
  • Posts: 71
SQLite basic setup help
« on: October 26, 2015, 08:44:54 pm »
I've read this page several times but just can't get SQLite to work for some reason:

http://wiki.freepascal.org/SQLite

I have a valid sqlite database containing one table, 'company'.

The file 'test.db' is in my application directory and the database name in the SQLConnection is set to the full path... /home/paul/lazarus/test.db. The transaction is set to SQLTransaction 1 which itself has the database set to SQLConnection1.

SQLQuery1 has a simple sql statement 'SELECT * FROM company', transaction property is set to SQLTransaction1.

The Datasource property is marked in red but is empty (is this right??).

I copied file libsqlite3.so.0.8.6 into my application directory and set SQLiteLibraryName:='libsqlite3.so.0.8.6';  in the form's OnCreate event (also tried adding the full path just in case).

Trying to set the query to active gives me a 'no such table' error.

I'm using Mint 17.1 with the latest Lazarus.

Any help appreciated as there's a growing face-shaped dent in my desk :D

Paul





engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: SQLite basic setup help
« Reply #1 on: October 26, 2015, 10:52:46 pm »
Sounds similar.

kapibara

  • Hero Member
  • *****
  • Posts: 518
Re: SQLite basic setup help
« Reply #2 on: October 27, 2015, 12:03:33 am »
Yes, Datasource should be left empty if the query doesn't need values from another dataset.

In those cases you can use the Datasource property to link to another query and use that for example like this, which gets 'item_id_from_other_dataset' from, well, another dataset:

Code: SQL  [Select]
  1. SELECT * FROM items WHERE item_id=:item_id_from_other_dataset

You can do Master/Detail that way.

Quote
The Datasource property is marked in red but is empty (is this right??).
Lazarus trunk / fpc 3.0.4 / Debian 10 - 64 bit

mrguzgog

  • Jr. Member
  • **
  • Posts: 71
Re: SQLite basic setup help
« Reply #3 on: October 27, 2015, 10:01:20 pm »
Sounds similar.

Yup, that's it in a nutshell and all resolved now, many thanks.

@kapibara: Thanks for the info - that will be useful :D