Paul, thanks again. I have what I hope will be my final question. I need to extract some data from the SQLite database and assign it to a FB variable. Again, I went to your TEST.BAS example and tried my hand at it. Here is the code I came up with:
Code: Select all
' ********************
' this sub provides user means to open an existing SQL database
' ********************
SUB db_open ()
clrArea(4, 23, 2, 79)
stInpStrg = ""
stSecName = "Open an Existing SQL Database"
heading (stSecName)
stFileStat = "open"
FileName ()
stDB = LTRIM(RTRIM(stInpStrg + stFileExt))
db.OpenDatabase(stDB)
pause(0)
REM choose row from BASELINE for computations
clrArea(4, 23, 2, 79)
stInpStrg = ""
LOCATE 7, 7 : PRINT "Choose record from BASELINE table for computations - "
LOCATE 9, 7 : choice(" ",8, 5, 6)
uiRecNo = VAL(stInpStrg)
sql = "SELECT * FROM baseline WHERE bl_rec_no = " + STR(uiRecNo) + ";"
q.PrepareQuery(db, sql)
REM db.SqlExec(sql)
DIM nRec AS UNSIGNED INTEGER
nRec = nRec + 1
FOR i = 0 TO q.ColumnCount - 1
BL.bl_rec_no = q.GetText(bl_rec_no)
BL.stTestDate = q.GetText(stTestDate)
BL.sfElev = q.GetText(sfElev)
NEXT
q.FinalizeQuery
LOCATE 5, 7 : PRINT "BL.bl_rec_no = " ; BL.bl_rec_no
LOCATE 6, 7 : PRINT "BL.stTestDate = " ; BL.stTestDate
LOCATE 7, 7 : PRINT "BL.sfElev = " ; BL.sfElev
pause(0)
main ()
END SUB
Here's the error msg when I attempt to compile:
Code: Select all
FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
standalone
target: win32, 486, 32bit
compiling: ptbcx3xx-sql.bas -o ptbcx3xx-sql.asm (main module)
ptbcx3xx-sql.bas(375) error 41: Variable not declared, bl_rec_no in 'BL.bl_rec_no = q.GetText(bl_rec_no)'
ptbcx3xx-sql.bas(376) error 41: Variable not declared, stTestDate in 'BL.stTestDate = q.GetText(stTestDate)'
ptbcx3xx-sql.bas(377) error 41: Variable not declared, sfElev in 'BL.sfElev = q.GetText(sfElev)'
I tried with and without quotes in the "q.GetText( )" statement. A lot of what's in my code above is for testing so it can be disregarded. I believe that this is the last SQLite function I need to perform so, hopefully, I won't need to bother you anymore. Your TEST.BAS helped me a lot but you may want to consider expanding it a bit ;-)))).
Bill