Hello.
I began experimenting with databases (sql), and I have a doubt that I cannot solve: I write a very basic code (based in examples from manual), in which a list appears with information (TextBox) and images (Image). With the "Next" menu,advance to the following cell of information and image, but if I use a filter, the correct images do not appear.
Some advice or help to solve this?
Mi code:
My Database is attached.
Thanks for read this.
Regards.
I began experimenting with databases (sql), and I have a doubt that I cannot solve: I write a very basic code (based in examples from manual), in which a list appears with information (TextBox) and images (Image). With the "Next" menu,advance to the following cell of information and image, but if I use a filter, the correct images do not appear.
Some advice or help to solve this?
Mi code:
B4X:
Sub Globals
cur_row=0
End Sub
Sub App_Start
Form1.Show
Con.New1
Reader.New1
Cmd.New1("",con.Value)
Con.Open("Data Source = " & AppPath & "\DB.sl3") 'Opens a connection with the database.
cmd.CommandText = txtCommand.Text 'Executes the SQL command
'Executes the user query and fills the table with the result.
cmd.ExecuteTable("table1",500) 'Limits the number of rows to 500 (change to 0 for unlimited)
Table1.SelectCell ("ID", 0)
Load
Showrow
End Sub
Sub Load 'Load image from database
cmd.CommandText = "SELECT image FROM Datos"
reader.Value = cmd.ExecuteReader
For i = 0 To table1.SelectedRow 'Find the right record.
reader.ReadNextRow
Next
Image1.Image = reader.GetImage(0)
Image1.Visible = True
reader.Close
Return
End Sub
Sub Table1_SelectionChanged (ColName, Row) event
Table1.SelectCell(Table1.SelectedCol, cur_row)
cur_row = Row
load
ShowRow
End Sub
Sub ShowRow
TextBox1.Text = Table1.Cell("Info" , cur_row)
Table1.SelectCell(Table1.SelectedCol, cur_row)
End Sub
Sub Nxt_Click
cur_row = (cur_row + 1) Mod table1.RowCount
Showrow
End Sub
Sub Previous_Click
cur_row = (cur_row + table1.RowCount-1) Mod table1.RowCount
Showrow
End Sub
Sub MemoryFilter_Click
Table1.Filter ("Category = 'Memory'")
Load
End Sub
Sub All_Click
Table1.Filter ("")
Table1.SelectCell ("ID", 0)
End Sub
My Database is attached.
Thanks for read this.
Regards.
Last edited: