Recent

Author Topic: Error trying to retrieve SQLite version  (Read 3479 times)

dietmar

  • Full Member
  • ***
  • Posts: 170
Error trying to retrieve SQLite version
« on: September 06, 2021, 04:25:12 pm »
Hello,

I am trying to determine the SQLite Version, and I get the error "SQLite3Connection: Database connect string (DatabaseName) not filled in". I can't find the error since I set up a name (and even hardcoding it didn't help).

Anyone finds the error?

Thx,
--Dietmar

Code:
Code: Pascal  [Select][+][-]
  1.   with SQLite3Connection do begin
  2.     DatabaseName := 'bla.db';
  3.     Open;
  4.     Connected := True;
  5.   end;
  6.   SQLTransaction.Active := True;
  7.   with SQLQuery.SQL do begin
  8.     Clear;
  9.     Add('select sqlite_version()')
  10.   end;
  11.   SQLQuery.Open;
  12.   stSQLiteVersion.Caption := 'SQLite v' + SQLQuery.FieldByName('sqlite_version()').AsString;
  13.  
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

balazsszekely

  • Guest
Re: Error trying to retrieve SQLite version
« Reply #1 on: September 06, 2021, 05:22:26 pm »
Hi dietmar,

Quote
I am trying to determine the SQLite Version, and I get the error "SQLite3Connection: Database connect string (DatabaseName) not filled in". I can't find the error since I set up a name (and even hardcoding it didn't help).

Anyone finds the error?

You did not assign a connection to SQLQuery via the Database property. The following code works fine at my side:
Code: Pascal  [Select][+][-]
  1.   SQLite3Connection.HostName := 'locahost';
  2.   SQLite3Connection.DatabaseName := ExtractFilePath(Application.Exename) + 'test.db';  //<-change the db name here
  3.   SQLite3Connection.Open;
  4.   if SQLite3Connection.Connected then
  5.   begin
  6.     SQLTransaction.DataBase := SQLite3Connection;
  7.     SQLTransaction.Active := True;
  8.  
  9.     SQLQuery.DataBase := SQLite3Connection;
  10.     SQLQuery.Transaction := SQLTransaction;
  11.     with SQLQuery.SQL do begin
  12.        Clear;
  13.        Add('select sqlite_version()')
  14.      end;
  15.      SQLQuery.Open;
  16.      if not SQLQuery.IsEmpty then
  17.        ShowMessage('SQLite v' + SQLQuery.FieldByName('sqlite_version()').AsString);
  18.   end;

The returned version is: 3.36.0

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Error trying to retrieve SQLite version
« Reply #2 on: September 06, 2021, 06:06:20 pm »
Wierd - I have set the connections between the 3 SQLite elements hardcoded via the object inspector.
But I just tried your code and get the same error!?! For me, it seems as if there is a problem with DatabaseNAME, but I cannot resolve it :(

--Dietmar
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

balazsszekely

  • Guest
Re: Error trying to retrieve SQLite version
« Reply #3 on: September 06, 2021, 06:25:19 pm »
Wierd - I have set the connections between the 3 SQLite elements hardcoded via the object inspector.
But I just tried your code and get the same error!?! For me, it seems as if there is a problem with DatabaseNAME, but I cannot resolve it :(

--Dietmar


Please test attached project. After you extract the archive, copy the appropriate(32/64 bit) sqlite3.dll into the project folder. According to your description "Lazarus 2.2.0RC1 with FPC 3.2.2 on Windows10 64Bit", you should download the 64 bit version.


PS: I tested both with 32/64 bit versions(Lazarus 2.0.12/Trunk, FPC 3.2.2). Works fine with every combination.
« Last Edit: September 06, 2021, 06:47:24 pm by GetMem »

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Error trying to retrieve SQLite version
« Reply #4 on: September 06, 2021, 08:31:39 pm »
Thanks for your effort!

But I don't get it. Although running on Win10 64Bit, with Lazarus 32Bit, loading the 64Bit-SQLite.dll gives error "file not found" or something like that. When using the 32 bit version, your test app works perfectly.
I compared your code line after line with my own - no difference. But my code doesn't work either :((

--Dietmar
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

balazsszekely

  • Guest
Re: Error trying to retrieve SQLite version
« Reply #5 on: September 06, 2021, 08:44:15 pm »
Quote
Although running on Win10 64Bit, with Lazarus 32Bit, loading the 64Bit-SQLite.dll gives error "file not found" or something like that.
Sorry, I should have been more specific: the SQLite bitness must mach Lazarus/FPC bitness. For some reason I assumed that you are using 64 bit Lazarus on Win10 64bit, which is clearly not the case.

Quote
I compared your code line after line with my own - no difference. But my code doesn't work either.
Can you please attach your project?

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Error trying to retrieve SQLite version
« Reply #6 on: September 07, 2021, 02:22:54 am »
Wierd - I have set the connections between the 3 SQLite elements hardcoded via the object inspector.
Maybe your application can not open SQLite because IDE already opened it in single threaded mode? Can you close IDE connection and try again? Just in case, read https://sqlite.org/threadsafe.html.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Error trying to retrieve SQLite version
« Reply #7 on: September 07, 2021, 06:33:41 pm »
Hi,

after cursing a lot while playing half the night with this issue, finally what did the trick was:

* closing the IDE
* deleting the "backup" and "lib" subdirectories of the project
* starting the IDE again
* building my project

I don't know what the reason was (perhaps a non-printable character in the DatabaseName?) but it's very annoying since this is the 3rd time I can only get rid of an error by performing the steps above.

Nevertheless, guys, thanks a lot for your help!

--Dietmar
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

 

TinyPortal © 2005-2018