* * *

Author Topic: SQLite queries at design-time doesn't work.  (Read 1635 times)

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 626
    • Burdjia
SQLite queries at design-time doesn't work.
« on: May 12, 2016, 01:05:22 pm »
I was following the FastReport tutorial using SQLite3.  I put the TSQLite3Connection, TSQLTransaction and TSQLQuery components, I "connect" the SQLite with the database file, then link with the transaction, then link the TSQLQuery component with the database and set the SQL query to retrieve data, and when I activate the query it shows an error message that says "no such table: employee".  If I open the query by code it doesn't throw any error.  What I see is that TSQLite3Connection doesn't open the database file (as it doesn't create the file if it doesn't exists as it does in run-time).  Is this an issue or a bug?  Or may be I'm doing something wrong?

I need to connect in design-time to configure the FastReport.  I'm sure it can be done by code, but...

And I followed the SQLdb tutorial before, but did all the connection by code.  Anyway, the table exists.
« Last Edit: May 12, 2016, 01:06:59 pm by Ñuño_Martínez »

JanRoza

  • Sr. Member
  • ****
  • Posts: 443
    • http://www.silentwings.nl
Re: SQLite queries at design-time doesn't work.
« Reply #1 on: May 12, 2016, 01:30:40 pm »
Hard to say something definitive without seeing your code, but did you also put a TFrDBDataset (lazReport component) on your form and linked this to your query?

engkin

  • Hero Member
  • *****
  • Posts: 1564
Re: SQLite queries at design-time doesn't work.
« Reply #2 on: May 12, 2016, 04:28:17 pm »
In design time the database is expected to be in the Lazarus folder. Most likely you were looking in the project folder for the newly created db.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 626
    • Burdjia
Re: SQLite queries at design-time doesn't work.
« Reply #3 on: May 12, 2016, 07:45:55 pm »
Hard to say something definitive without seeing your code, but did you also put a TFrDBDataset (lazReport component) on your form and linked this to your query?
Yes, I did, and checked twice to be sure.  Always check twice.

BTW, I've found what happens:

First, I forgot to say that I'm using Xubuntu.

In run-time, it looks for the database file at the executable directory, but in design-time it looks for it at the $HOME directory.  So, if I have a copy of the database at $HOME it works.

Note that if I put the full path (like "/home/guillermo/projects/program/database.sqlite") in design-time it still looks for database at $HOME.

I think it is not the desired behaviour, so it is a bug, isn't it?

 

Recent

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