I’ve been following the example of EddiesElectronics where the search field contents is able to search the database and return values to the list box. However, I’ve had no luck In Implementing this myself.
I have three methods in the page as follows.
FindPatientsByName
Dim stmt As SQLitePreparedStatement
stmt = session.db.Prepare("SELECT Forename, Surname, DateOfBirth, Address FROM Patients WHERE Forename LIKE ? OR Surname LIKE ? ORDER BY Forename, Surname")
stmt.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
stmt.BindType(1, SQLitePreparedStatement.SQLITE_TEXT)
stmt.Bind(0, SearchName+"%")
stmt.Bind(1, SearchName+"%")
Dim rs As RecordSet = stmt.SQLSelect
Return rs
PatientSearchUpdate
Dim patientRS As RecordSet
patientRS = FindPatientsByName(searchText)
If patientRS <> Nil Then
lbSearch.DeleteAllRows
For i As Integer = 1 To patientRS.RecordCount
lbSearch.AddRow(patientRS.Field("Forename").StringValue + ", " + patientRS.Field("Surname").StringValue)
patientRS.MoveNext
Next
lbSearch.ListIndex = 0
patientRS.Close
End If
LoadPatients
Dim patientRS As RecordSet
patientRS = FindPatientsByName(searchText)
If Session.DB is Nil Then Return
Dim sql As Text = "SELECT Forename, Surname, DateOfBirth, Address FROM Patient ORDER BY Forename"
Dim patients As RecordSet = Session.DB.SQLSelect(sql)
If Session.DB.Error Or patients is Nil Then
MsgBox("Error: " + Session.DB.ErrorMessage)
Return
End If
While Not patients.EOF
lbSearch.AddRow(Patients.field("Forename").StringValue, patients.field("Surname").StringValue, patients.field("DateOfBirth").StringValue, patients.field("Address").StringValue)
patients.MoveNext
Wend
patients.close
I’ve been trying for hours and nothing I seem to do works. I type into the search bar and the list box doesn’t change at all. I’ve tried to make it as close to the Eddies Electronics example as possible but it’s not worked out. My ‘LoadPatients’ Is rather different to the example counterpart, but that’s because my ListBox would not load any data at all when I followed the examples version. Would really appreciate if someone can tell me why it’s not working.
Thanks