PlanetSquires Forums

Support Forums => WinFBE - Code Editor and Visual Designer => Topic started by: SeaVipe on November 01, 2018, 07:54:33 PM

Title: WinFBE - SQLite3
Post by: SeaVipe 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
Title: Re: WinFBE - SQLite3
Post by: Paul Squires on November 01, 2018, 10:23:41 PM
Are you using Jose's CSqlite3.inc code found in WinFBX?
Title: Re: WinFBE - SQLite3
Post by: Paul Squires 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 :)
Title: Re: WinFBE - SQLite3
Post by: SeaVipe 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

Title: Re: WinFBE - SQLite3
Post by: Paul Squires 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.
Title: Re: WinFBE - SQLite3
Post by: SeaVipe 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!
Title: Re: WinFBE - SQLite3
Post by: Paul Squires on November 01, 2018, 11:17:17 PM
:-)  you're very welcome