Mysql Query

Following the Mysql Sample Project, how to do querying the data into listbox, based from textfield’s criteria,

this code still showing an error ’ unkown column ‘’ in where clause.

If Not IsConnected Then
MsgBox(“Connect to the database first.”)
End If

Dim sql As String
sql = “SELECT * FROM Team WHERE name =” + TextField5.Text

Dim data As RecordSet
data = mDB.SQLSelect(sql)

If mDB.Error Then
MsgBox("DB Error: " + mDB.ErrorMessage)
End If

If data <> Nil Then
While Not data.EOF
DataList.AddRow(data.IdxField(1).StringValue, data.IdxField(2).StringValue, _
data.IdxField(3).StringValue, data.IdxField(4).StringValue)


End If[/code]

anyone knows whats missing ?


+  "'" + TextField5.Text + "'"

What follows next is a long conversation about why this simplistic approach will cause you trouble in the long term.
Read up about parameterised queries.

Dear Jeff,

Thanks for the code,
but its seem the code only showing the result while I do typing the criteria completely.
how to make it autocomplete.

how to make it like,
there are names, crows, crows parker, crows johan,

what I need is, while I am typing ‘cro’ in the textfield, the listbox filled with data contains name with ‘cro’


Put your query in the textfield’s KeyDown event.

its solved, I change the query into,

sql = "SELECT * FROM Team WHERE name LIKE '%" + TextField5.Text + "%'"


Now try to enter Max’s team into Textfield5 and see what happens. Then follow the advice given to you here about prepared statements.


is there anyway to do querying data base from any columns ?

sql = "SELECT * FROM Team WHERE name LIKE '%"  + TextField5.Text + "%'"

I have 10 fields, and I want to querying data in all columns which is match.

I found it on the web, its easy on php.


Use Xojo to create a PREPARED STATEMENT using the database table schema data… this way you can have access to all the field names and build the PREPARED STATEMENT dynamically even if the table name or table schema changes

and the link you provided is JSQuery… not ANSI SQL

Hi Mr. S,

Some code sample would be great…


Just search for ‘prepared’ in the forum. Lots of examples around.