Here is a simple app that I'm getting an invalid SET NUMBER error. I can create the DB and add records but I get the error when i try to read records. Sorry this is the first try with SQLightning so I'm stupid
the error is in the FORM1_BOPENDB_BN_CLICKED routine
=======>>> Set Numbers
%snContacts = 1
%snStationInfo = 2
'--------------------------------------------------------------------------------
Function FORM1_BCREATE_BN_CLICKED ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idButtonControl As Long _ ' identifier of button
) As Long
' ==========>>> SQLitening -- Open
' This will open the main database. We will include the "C" ModChar
' which will create the file if it does not already exist. The extension
' can be anything you like. SQLite likes .Db3 while I prefer .Sld -- your
' choice.
slOpen "HamLog.Sld", "C"
' ==========>>> SQLitening -- Exe
' Begin transaction
slExe "Begin"
'MsgBox "begin"
' ==========>>> SQLitening -- Exe
' Drop all the main tables if they exist. We do this because we want
' to start with empty tables each time this example is run. Note that
' we do all the drops in one slExe command
slExe "Drop Table If Exists Customers; Drop Table If Exists Parts;" & _
"Drop Table If Exists Orders; Drop Table If Exists LineItems"
'
' ==========>>> SQLitening -- Exe
' Create the Contact table. Note that the CustomerID will be the same value
' as the built-in RowID but we do not want a new customer to get the same number
' as a deleted one so we add the Autoincrement keyword. We do not assign a type
' to Name and City. A great thing about SQLite is that the type of a value is
' associated with the value itself, not with the column in which the value is
' stored.
slExe "Create Table Contacts (cID Integer Primary Key Autoincrement, Call_Sign, Fname,Lname)"
' ==========>>> SQLitening -- Exe
' Create the Station info table. Same concept as Customers.
slExe "Create Table Station_Info (sID Integer Primary Key Autoincrement, Rig, Antenna)"
slExe "End"
End Function
'--------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ ' optional user defined Long value
) As Long
createListHeaders
End Function
Sub createListHeaders()
FF_ListView_InsertColumn( HWND_FORM1_LISTVIEW1, 0, "Call Sign", %LVCFMT_CENTER ,75)
FF_ListView_InsertColumn( HWND_FORM1_LISTVIEW1, 1, "First Name", %LVCFMT_CENTER ,75)
FF_ListView_InsertColumn( HWND_FORM1_LISTVIEW1, 2, "Last Name", %LVCFMT_CENTER ,75)
FF_ListView_InsertColumn( HWND_FORM1_LISTVIEW1, 3, "Rig", %LVCFMT_CENTER ,75)
FF_ListView_InsertColumn( HWND_FORM1_LISTVIEW1, 4, "Antenna", %LVCFMT_CENTER ,75)
End Sub
'--------------------------------------------------------------------------------
Function FORM1_BADDONE_BN_CLICKED ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idButtonControl As Long _ ' identifier of button
) As Long
Local Callsign As String
Local Fname As String
Local Lname As String
Local Rig As String
Local Antenna As String
Callsign= FF_TextBox_GetText( HWND_FORM1_TXTCALLSIGN )
Fname = FF_TextBox_GetText( HWND_FORM1_TXTFIRSTNAME )
Lname = FF_TextBox_GetText( HWND_FORM1_TXTLASTNAME )
Rig =FF_TextBox_GetText( HWND_FORM1_TXTRIG )
Antenna = FF_TextBox_GetText( HWND_FORM1_TXTANTENNA )
' Begin transaction
slExe "Begin"
slExe slBuildInsertOrUpdate("Contacts", Callsign & $Nul & Fname & $Nul & Lname,"Call_Sign,Fname,Lname")
slExe slBuildInsertOrUpdate("Station_Info", Rig & $Nul & Antenna ,"Rig,Antenna")
' End transaction
slExe "End"
End Function
'--------------------------------------------------------------------------------
Function FORM1_BOPENDB_BN_CLICKED ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idButtonControl As Long _ ' identifier of button
) As Long
Local Numflds As String
Local rec As String
Local i As Long
' Process records
Do While slGetRow(%snContacts) ' I get the error here
' When a row is returned, you use the slF, slFN, slFX, slFNX functions.
Rec = ""
For i = 1 To slGetColumnCount
MsgBox Str$(slGetRow) & " " & Str$(slGetColumnCount)
Rec = Rec & slF(i) & " - "
Next
ztrace Rec & $Nul
Loop
End Function
In your FORM1_BOPENDB_BN_CLICKED you are trying to slGetRow on nothing! You need to create a recordset first by issuing an slSel call. Once slSel finishes then a recordset will exist. You iterate over that recordset using slGetRow.
Also, in your FORM1_BCREATE_BN_CLICKED you are slOpen but not slClose. This means that if you try to do the FORM1_BOPENDB_BN_CLICKED without first doing the create then the database will not be open. In your FORM1_BOPENDB_BN_CLICKED you should slOpen, slSel, slGetRow and finally slClose.
Hope that solves the problem. :)
Thank you Paul I'll give it a try. Sorry to bother you, I'll get the hang of SQLightning soon