I have simplified the code by putting everthing into the Open event of CustomerList listbox.
Orders is a property of Window1 of type ODBCDatabase.
From this, it doesn’t look like there is anything wrong with the design of EE after all.
This code works
[code] Orders = New ODBCDatabase
Orders.DataSource = “Conversion”
If not Orders.Connect then
MsgBox("Error: " + Orders.ErrorMessage)
end if
dim searchName As String = “”
Dim sql As String
sql = “SELECT * FROM Customers WHERE lastname LIKE '” +searchName+"%"+"’ OR firstname LIKE ‘" _
+searchName+"%"+"’ ORDER BY lastname, firstname"
Dim rs As RecordSet = Orders.SQLSelect(sql)
'Dim stmt As ODBCPreparedStatement
'stmt = ODBCPreparedStatement(Orders.Prepare(“SELECT * FROM Customers WHERE lastname LIKE ? OR firstname LIKE ? ORDER BY lastname, firstname”))
'stmt.BindType(0, ODBCPreparedStatement.ODBC_TYPE_STRING)
'stmt.BindType(1, ODBCPreparedStatement.ODBC_TYPE_STRING)
’
'stmt.Bind(0, searchName+"%")
'stmt.Bind(1, searchName+"%")
’
'Dim rs As RecordSet = stmt.SQLSelect
If rs <> Nil Then
CustomerList.DeleteAllRows
//For i As Integer = 1 To rs.RecordCount
While Not rs.EOF
CustomerList.AddRow(rs.field("lastname").StringValue + ", " + rs.Field("firstname").StringValue)
CustomerList.RowTag(CustomerList.LastIndex) = rs.Field("ID").IntegerValue
rs.MoveNext
Wend
//Next
CustomerList.ListIndex = 0
rs.Close
End If
[/code]
This code does not work
[code] Orders = New ODBCDatabase
Orders.DataSource = “Conversion”
If not Orders.Connect then
MsgBox("Error: " + Orders.ErrorMessage)
end if
dim searchName As String = “”
'Dim sql As String
‘sql = “SELECT * FROM Customers WHERE lastname LIKE '” +searchName+"%"+"’ OR firstname LIKE '" _
‘+searchName+"%"+"’ ORDER BY lastname, firstname"
’
'Dim rs As RecordSet = Orders.SQLSelect(sql)
Dim stmt As ODBCPreparedStatement
stmt = ODBCPreparedStatement(Orders.Prepare(“SELECT * FROM Customers WHERE lastname LIKE ? OR firstname LIKE ? ORDER BY lastname, firstname”))
stmt.BindType(0, ODBCPreparedStatement.ODBC_TYPE_STRING)
stmt.BindType(1, ODBCPreparedStatement.ODBC_TYPE_STRING)
stmt.Bind(0, searchName+"%")
stmt.Bind(1, searchName+"%")
Dim rs As RecordSet = stmt.SQLSelect
If rs <> Nil Then
CustomerList.DeleteAllRows
//For i As Integer = 1 To rs.RecordCount
While Not rs.EOF
CustomerList.AddRow(rs.field("lastname").StringValue + ", " + rs.Field("firstname").StringValue)
CustomerList.RowTag(CustomerList.LastIndex) = rs.Field("ID").IntegerValue
rs.MoveNext
Wend
//Next
CustomerList.ListIndex = 0
rs.Close
End If
[/code]