WinFBE - SQLite3

Started by SeaVipe, November 01, 2018, 08:24:33 PM

Previous topic - Next topic

SeaVipe

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
Clive Richey

Paul Squires

Are you using Jose's CSqlite3.inc code found in WinFBX?
Paul Squires
PlanetSquires Software

Paul Squires

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 :)
Paul Squires
PlanetSquires Software

SeaVipe

#3
Will do...
Cut'Paste



'#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

Clive Richey

Paul Squires

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.
Paul Squires
PlanetSquires Software

SeaVipe

Those damn trees! Aye yi yi.


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


Thanks Paul!
Clive Richey

Paul Squires

Paul Squires
PlanetSquires Software