Hi,
I converted my working REALSQLdatabase to a SQLiteDatabase, but now I receive an error “cannot write to database” whenever I try to write to it?
I am now totally perplexed??
Please help
This is the code in my save to database button:
[code] dim rx as new RegEx
rx.SearchPattern = “[1-9]”
dim match as RegExMatch = rx.Search( fldAmount.Text )
if match is nil then // Doesn’t have a number
MsgBox(“You need to enter an amount before saving!”)
else // Does have a number
dim insertRec as new DatabaseRecord
insertRec.Column( “Date” ) = fldDate.text
insertRec.Column( “Description” ) = fldDescription.text
fldAmount.text=ReplaceAll(fldAmount.text, “,”, “”)
insertRec.Column( “Income” ) = fldAmount.text
insertRec.Column( “IsIncome” ) = fldIsIncome.text
db.InsertRecord( “Accounts”, insertRec )
db.commit
Window1.RefreshListBox.mode=Window1.RefreshListBox.ModeSingle
self.close
end if
if db.error then
db_error
self.close
end if[/code]
The RefreshListBox Timer (near the bottom of that code) contains the following code:
Window1.PopulateAccounts(Window1.lb_accounts,db,"select ACRef, Date, Description, Income, Expenses, IsIncome from Accounts order by Date desc")
The PopulateAccounts method contains the following code:
lb_accounts.deleteAllRows
// run the query
rs=db.sqlSelect(sql )
if rs = NIL then
db_error
exit sub
end if
// populate the listbox
while not rs.eof
lb_accounts.addRow ""// add a new row
for i as integer = 1 to rs.fieldCount// add data to columns
select case i-1
case 0,1,2,5 // leave columns 0, 1, 2, and 5 untouched
lb_accounts.cell(lb_accounts.lastIndex, i-1) = rs.idxField(i).stringValue
case 3,4 // reformat columns 3 and 4 (income and expenses)
lb_accounts.cell(lb_accounts.lastIndex, i-1) = format(rs.idxField(i).CurrencyValue,"###,##0.00")
end select
if lb_accounts.cell(lb_accounts.lastIndex, i-1) = "0.00" then
lb_accounts.cell(lb_accounts.lastIndex, i-1) = ""
end if
next
rs.moveNext// move to next record
wend
The parameters for the above method are as follows:
lb as listbox, db as sqlitedatabase, sql as string