* * *

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

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 747
    • 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 »
Are you interested in game programming? Join the Pascal Game Development community!

JanRoza

  • Sr. Member
  • ****
  • Posts: 488
    • 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?
OS: Windows 10 (64 bit)
Laz: Lazarus 1.8.2 FPC 3.0.4 i386-win32-win32/win64

engkin

  • Hero Member
  • *****
  • Posts: 1947
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: 747
    • 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?
Are you interested in game programming? Join the Pascal Game Development community!

 

Recent

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