I am trying my hand at accessing a SQLite3 database using Freebasic.
I looked at this post: viewtopic.php?p=210774#p210774 and tried the class and test.bas but I get the following errors when I try to compile the test.bas program:
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(90) error 42: Variable not declared, sqlite3_api in 'psz = sqlite3_libversion'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(99) error 9: Expected expression, found 'sqlite3_api' in 'Function = sqlite3_libversion_number()'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(100) warning 13(1): Function result was not explicitly set
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(108) error 9: Expected expression, found 'sqlite3_api' in 'psz = sqlite3_sourceid'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(141) error 9: Expected expression, found 'sqlite3_api' in 'Dim rc As Integer = sqlite3_open( DBName, @m_dbHandle)'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(154) error 9: Expected expression, found 'sqlite3_api' in 'Dim rc As Integer = sqlite3_close(m_dbHandle)'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(166) error 99: No matching overloaded function, LASTERROR() in 'this.LastError = sqlite3_exec(this.dbHandle, sql, 0, 0, @errmsg)'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(167) error 3: Expected End-of-Line, found 'sqlite3_api' in 'sqlite3_free(errmsg)'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(178) error 9: Expected expression, found 'sqlite3_api' in 'pzSql = sqlite3_mprintf("%q", sql)'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(180) error 3: Expected End-of-Line, found 'sqlite3_api' in 'sqlite3_free(pzSql)'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(206) error 3: Expected End-of-Line, found 'sqlite3_api' in 'sqlite3_finalize(this.hstmt)'
C:\FreeBASIC\fltk-c-1.3.3\clsSqlite3.bas(206) error 133: Too many errors, exiting
Results:
Compilation failed
Any advice?
FreeBasic/SQL
Re: FreeBasic/SQL
I just compiled with the newest official release of the FB compiler and it worked. What version of the compiler are you using?
Re: FreeBasic/SQL
Maybe you could try my own sqlite implementation:
sqlite3.bi
data.bi
data.bas
you should include only data.bi anywhere you need to perform sql queries, here is a dummy example:
sqlite3.bi
data.bi
data.bas
you should include only data.bi anywhere you need to perform sql queries, here is a dummy example:
Code: Select all
#include "data.bi"
Dim myDST as DataSet, sql as string
OpenConnection("data.s3db")
sql = "SELECT * FROM myTable"
myDST = FetchData(sql)
CloseConnection()
For i as ulong = 0 to myDST.RowCount
For j as ulong = 0 to myDST.Rows(i).FieldCount
Print myDST.Rows(i).Fields(j).Value
Next j
Next i
Re: FreeBasic/SQL
It looks like you need to declare the 'sqlite3_api' variable before using it in your code. The 'sqlite3_api' variable is used to access the functions exposed by the SQLite3 library.
To declare the 'sqlite3_api' variable, you need to add a line of code at the top of your program:
Declare Function sqlite3_api Lib "sqlite3.dll" Alias "sqlite3_api" () As Any
Once you add this line of code, the compiler should be able to find the 'sqlite3_api' variable and you should be able to compile and run your program successfully.
To declare the 'sqlite3_api' variable, you need to add a line of code at the top of your program:
Declare Function sqlite3_api Lib "sqlite3.dll" Alias "sqlite3_api" () As Any
Once you add this line of code, the compiler should be able to find the 'sqlite3_api' variable and you should be able to compile and run your program successfully.
Re: FreeBasic/SQL
Check this problem post might be helpful.
Re: FreeBasic/SQL
A lead time of nearly two months for the lowest grade spam imaginable? I guess they didn't pay for a particularly advanced package