Help DB sqlite

Hello everyone
I am a neophyte of Xojo and wonder if you can help in the management of a small database because the DataControl is not working.

I loaded the contents of a table in a listbox sqlite

Now I would like to withdraw the record from the list box and change it.

I would like to add more or delete records

I would like to move between records with previus, next, first and last

I saw the material but were not very clear.
If you can include a small source learning there would be grateful

Thanks for your help

Greetings to all

What have you tried that hasn’t worked?

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

In your second set of code, you are not connecting to the database. You should have another db.connect call there.

Thank you
I looked looked so many times but I never took this detail
Greetings and thanks