Hi,
I am trying to save the data from a Stylegrid to an sql database.
Not entirely sure that I am doing it correct, the code appears to collect the data correctly from the cells but I keep getting a message from the CEditDirect class, that the table "users" does not contain a column "myname" or the column "myname" is not unique.
Does anyone have any experience using the Stylgrid with the edit class.
Here is my code to save the data.
dim a,ColumnCount as Integer
dim db1 as new REALSQLDatabase
dim rec As DatabaseRecord
dim f As FolderItem = SpecialFolder.Desktop.Child("customer.sqlite")
If f<>Nil then //if the user didn't cancel..
If f.exists then //if it is a valid file...
db1.databaseFile = f
else
MsgBox "Database File not found!"
end if
end if
if not db1.databaseFile.exists then
msgbox "Can not find database"
end if
if not db1.Connect then
msgbox "Can not Connect to database"
end if
ColumnCount = StyleGrid3.Cols
for a = 1 to ColumnCount
// create a new record and fill in the data from the row
rec = new databaseRecord
rec.column( "myname" )= StyleGrid3.CellText(a,1)
rec.column( "address1" )= StyleGrid3.CellText(a,2)
rec.column( "address2" )= StyleGrid3.CellText(a,3)
// insert the record
db1.insertRecord "users",rec
if db1.error then// check for errors
msgBox db1.errorMessage
return
end
next
// commit changes to database
db1.commit
Regards
John