PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: WinFBE - SQLite3  (Read 470 times)

SeaVipe

  • Junior Member
  • **
  • Posts: 171
  • Windows 10 Ubuntu 18
WinFBE - SQLite3
« on: November 01, 2018, 07:54:33 PM »

I'm attempting (considering) development of an SQLite3 app in WinFBE (strictly a test application as a learning tool) to replace an FF3 app. The FF3 app does not use SQLite.
[/size]I've run into a problem right off the bat: "unable to load sqlite3.dll" even though I have the DLL in the same folder as the source code. Question: what is the correct dll and where should it reside?
Thanks, Clive
Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8824
  • Windows 10
    • PlanetSquires Software
Re: WinFBE - SQLite3
« Reply #1 on: November 01, 2018, 10:23:41 PM »

Are you using Jose's CSqlite3.inc code found in WinFBX?
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8824
  • Windows 10
    • PlanetSquires Software
Re: WinFBE - SQLite3
« Reply #2 on: November 01, 2018, 10:26:31 PM »

If you can post a zip or rar copy of your project then I will test it on my machine as well and we'll both get it working :)
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Junior Member
  • **
  • Posts: 171
  • Windows 10 Ubuntu 18
Re: WinFBE - SQLite3
« Reply #3 on: November 01, 2018, 10:28:59 PM »

Will do...
Cut'Paste

Code: [Select]

'#CONSOLE ON
#define UNICODE
#INCLUDE ONCE "Afx/AfxWin.inc"
#INCLUDE ONCE "Afx/CSQLite3.inc"
USING Afx

' // Optional: Specify the DLL path and/or name
' // This allows to use a DLL with a different name that sqlite3.dll,
' // located anywhere, avoiding the neeed to have multiple copies of the same dll.
DIM pSql AS CSQLite = "sqlite3_64.dll"
print pSql.m_hLib

' // Create a new database
' // I'm deleting and recreating the database for testing purposes
DIM cwsDbName AS CWSTR = AfxGetExePathName & "Test.sdb"
IF AfxFileExists(cwsDbName) THEN AfxDeleteFile(cwsDbName)
DIM pDbc AS CSQLiteDb = cwsDbName

' // Create a table
IF pDbc.Exec("CREATE TABLE t (xyz text)") <> SQLITE_DONE THEN
   AfxMsg "Unable to create the table"
   END
END IF

' // Insert rows
IF pDbc.Exec("INSERT INTO t (xyz) VALUES ('fruit')") <> SQLITE_DONE THEN AfxMsg "INSERT failed"
IF pDbc.Exec("INSERT INTO t (xyz) VALUES ('fish')") <> SQLITE_DONE THEN AfxMsg "INSERT failed"

' // Prepare a query
DIM pStmt AS CSqliteStmt = pDbc.Prepare("SELECT * FROM t")
PRINT "Column count: ", pStmt.ColumnCount
' // Read the column names and values
DO
   ' // Fetch rows of the result set
   IF pStmt.GetRow = SQLITE_DONE THEN EXIT DO
   ' // Read the columns and values
   FOR i AS LONG = 0 TO pStmt.ColumnCount- 1
      PRINT pStmt.ColumnName(i)
      PRINT pStmt.ColumnText(i)
   NEXT
LOOP

PRINT
PRINT "Press any key..."
SLEEP

« Last Edit: November 01, 2018, 10:32:58 PM by SeaVipe »
Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8824
  • Windows 10
    • PlanetSquires Software
Re: WinFBE - SQLite3
« Reply #4 on: November 01, 2018, 10:52:32 PM »

It worked perfectly for me. I expect that when you switched to using the sqlite3_64.dll that you didn't also switch WinFBE to compile in 64 bit mode? You will get that error if you use a 32 bit compiled WinFBE exe with the 64 bit sqlite dll.

You can get both sqlite dlls from https://sqlite.org/download.html

I downloaded them from that link and renamed each sqlite3_32.dll and sqlite3_64.dll. I used your code and changed WinFBE to compile 32 bit and 64 bit exe's. No issues.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Junior Member
  • **
  • Posts: 171
  • Windows 10 Ubuntu 18
Re: WinFBE - SQLite3
« Reply #5 on: November 01, 2018, 11:10:08 PM »

Those damn trees! Aye yi yi.


Made no changes other than to switch to Win64 Console (debug).


Thanks Paul!
Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8824
  • Windows 10
    • PlanetSquires Software
Re: WinFBE - SQLite3
« Reply #6 on: November 01, 2018, 11:17:17 PM »

:-)  you're very welcome
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer