This code works, either with the commented out first statement that has field values hard coded or the second one that uses variables:
'var sql As String = "SELECT A.SerNo, A.Model, A.MeterID, A.LynxKey, B.Name, B.Port, B.MtrID, B.LynxKey FROM Meters A Left JOIN Units B ON A.MeterID = B.MtrID "+_
'“WHERE A.SerNo = 67530 AND A.MeterID <> 0 AND A.LynxKey = 8 AND B.LynxKey = 8”var sql As String = "SELECT A.SerNo, A.Model, A.MeterID, A.LynxKey, B.Name, B.Port, B.MtrID, B.LynxKey FROM Meters A LEFT JOIN Units B ON A.MeterID = B.MtrID "+_
“WHERE A.SerNo = " + tfSerNo.Text + " AND A.MeterID <> " + str(recID) +” AND A.LynxKey = “+Session.LynxKey+” AND B.LynxKey = " + Session.LynxKeyvar rs As RowSet = Session.db.SelectSQL(sql)
This code throws a database exception 1 - near “A”: syntax error
var sql As String = "SELECT A.SerNo, A.Model, A.MeterID, A.LynxKey, B.Name, B.Port, B.MtrID, B.LynxKey FROM Meters A LEFT JOIN Units B ON A.MeterID = B.MtrID "+_
“WHERE A.SerNo = ? AND A.MeterID <> ? AND A.LynxKey = ? AND B.LynxKey = ?”var rs As RowSet = Session.db.SelectSQL(sql, tfSerNo.Text, recID, Session.LynxKey, Session.LynxKey)
At this time, there are no records in either of the two tables. All the variables are numeric. All are stored as strings except recID which is stored as Integer. I have retyped the bottom statement and run it numerous times with small changes, but I cannot get it to work as a prepared statement. I’m starting to wonder about the reliability of the new automatic prepared statements.