Hi Tim,
I tried to look around a bit, but frankly I’m a little confused.
Connect the database correctly
Populates the listbox properly in this way
'Cancellation list
Listbox1.DeleteAllRows
'Opening the database
Dim dbFile As FolderItem
Dim db As New SQLiteDatabase
dbr dim as recordset
dbFile = GetFolderItem (“C: \ Users \ Rico Vast \ Documents \ project-xojo / database.sqlite”)
db.DatabaseFile = dbFile
'Label4.Text = dbfile.Name
Then if db.connect
// Proceed with database operations here …
'MsgBox (“Data base successfully opened”)
'Queries generic creating the recordset
dbr = db.SQLselect (“Select * from test”)
ListBox1.ColumnCount = 3
ListBox1.HasHeading = True
ListBox1.Heading (0) = "code"
ListBox1.Heading (1) = "Name"
ListBox1.Heading (2) = "Name"
If dbr <> Nil Then
While Not dbr.EOF
ListBox1.AddRow (dbr.field ("Code"))
ListBox1.Cell (ListBox1.LastIndex, 1) = dbr.field ("Last Name")
ListBox1.Cell (ListBox1.LastIndex, 2) = dbr.field ("Name")
dbr.MoveNext
Wend
dbr.MoveFirst
dbr.Close
End If
Else
MsgBox (“Do not be opened because the Db. Error:” + db.ErrorMessage)
End If
I try to select the record to the list box to edit it in this way:
Dim db As New SQLiteDatabase
Dim dbFile As FolderItem
dim selected as string
Label1.Text = listbox1.ListIndex.ToText
selected = Listbox1.Cell (ListBox1.Listindex, 0) .ToText
dbFile = GetFolderItem (“C: \ Users \ Rico Vast \ Documents \ project-xojo / database.sqlite”)
db.DatabaseFile = dbFile
Dim ps As SQLitePreparedStatement
ps = db.Prepare (“SELECT * FROM test WHERE code =?”)
ps.BindType (0, SQLitePreparedStatement.SQLITE_TEXT)
‘Ps.BindType (1 SQLitePreparedStatement.SQLITE_INTEGER)’ other parameter
ps.Bind (0 selected) 'passes the parameter
Dim RecordSet As dbr
dbr = ps.SQLSelect
Label1.Text = selected
if dbr <> Nil then
While not dbr.eof
MsgBox (“Name:” + dbr.Field (“Code”). StringValue)
codicetxt.Text = dbr.Field (“Code”). StringValue
dbr.MoveNext
Wend
else
If db.Error Then MsgBox (db.ErrorMessage)
end if
Surely there is something I can not do.
Thanks for your help
I state that I only have some experience with morfik