Recent

Author Topic: SQLight: No such table  (Read 4665 times)

perhen

  • New Member
  • *
  • Posts: 15
SQLight: No such table
« on: February 16, 2018, 03:47:20 pm »
Hello
I am trying to see data from a SQLight table during design of en application, but I always get the message No such table: <tablename> when I try to set active property of the query to true. I do have a connection component with connected property set to true and a transaction component with active property set to true. the database property of the query is the name of the connection component. When I run query.open; then thing works.
I wonder if it is possible to se data, say in a TDBGrid during design which I expected when setting the query action to true in Object Inspector.

Can anybody tell me if that is possible and what I probably have missed out if it is possible?

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
Re: SQLight: No such table
« Reply #1 on: February 16, 2018, 04:40:02 pm »
Have you set a SQL select statement in the SQL proprty kf your query?
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

perhen

  • New Member
  • *
  • Posts: 15
Re: SQLight: No such table
« Reply #2 on: February 16, 2018, 07:55:05 pm »
Yes, SELECT * FROM <tablename>. I keep it as simple as possible.

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: SQLight: No such table
« Reply #3 on: February 16, 2018, 08:50:05 pm »
The problem may be in your connection. Did you set database with full path?
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

perhen

  • New Member
  • *
  • Posts: 15
Re: SQLight: No such table
« Reply #4 on: February 17, 2018, 02:52:42 pm »
I have tried with and without full path. Same result. I have rhe database in sae directory. The database file is made with SQLightManager. I have attached my application in a zip-file. The file sqlite3.dll is removed from directory because of size.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: SQLight: No such table
« Reply #5 on: February 17, 2018, 03:41:09 pm »
I have tried with and without full path. Same result. I have rhe database in sae directory. The database file is made with SQLightManager. I have attached my application in a zip-file. The file sqlite3.dll is removed from directory because of size.
for me it opens with out problems see attachment. I suggest to
1) make sure that no other database with the same name can be found and opened some times the current directory might not point to your application's directory.
2) delete the query, ds and grid and place them again. and make sure they are not double clicked or changed in any way other than the link between them.

In my case I used the sqlitespy to open the database and make sure the table existed I created the select statement from that app and executed it on that app too then copied the select I knew it worked on the qeury.sql property and it openeded fine. Is there a chance that the name in your sql does not have the correct characters? they might look the same but some character is a national character instead of the english one?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: SQLight: No such table
« Reply #6 on: February 17, 2018, 03:45:33 pm »
Quote
1) make sure that no other database with the same name can be found and opened some times the current directory might not point to your application's directory.
Look especially in the Lazarus directory !! When opening the database in the Lazarus IDE, it could be that the DB is opened for your lazarus.exe and not your program. SQLite would then first look in the C:\Lazarus directory (or directory where lazarus.exe sits). If it doesn't find it there it might look in your program directory.

When running outside the IDE, it does look first in your project.exe directory (because in that case SQLite will open it for your project.exe).

So, you probably have an empty test.db in your lazarus directory without any tables.
« Last Edit: February 17, 2018, 03:47:16 pm by rvk »

perhen

  • New Member
  • *
  • Posts: 15
Re: SQLight: No such table
« Reply #7 on: February 17, 2018, 10:40:59 pm »
Thank you all for your responses. My problem is solved :D I found a lot of empty database files in my lazarus directory. I did not know they were created. Now I can get on further with my project. :)

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: SQLight: No such table
« Reply #8 on: February 18, 2018, 01:21:40 am »
Quote
I did not know they were created.

If SQLite don't find the database then SQLite creates it. So it's very recomedable to use if FileExists before you make a connection.
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

 

TinyPortal © 2005-2018