I am using the following code to get the "setpoint" record from the "Zones" table of a Database.
I need to filter this on 2 fields: "ToolName" and "Zone"
The app compiles, but I get a syntax error when running the app.
B4X:
Dim MyTool As String
Dim MyZoneNum As String
Dim MySetPoint As String
MyTool = lblSetupTool.Text
MyZoneNum = MyZone.Substring(6)
Dim Curs As Cursor
Curs = SQL.ExecQuery2("SELECT setpoint FROM Zones WHERE ToolName = " & MyTool & " AND WHERE Zone = " & MyZoneNum & "", Array As String(Value))
Dim i As Int
For i = 0 To Curs.RowCount - 1
Curs.Position = i
MySetPoint = Curs.GetString("SetPoint")
Next
Curs.Close
you either concatenate the value OR use the array method and use a ? where the value should be.
B4X:
Curs = SQL.ExecQuery("SELECT setpoint FROM Zones WHERE ToolName = '" & MyTool & "' AND Zone = '" & MyZoneNum & "' ")
'versus
Curs = SQL.ExecQuery2("SELECT setpoint FROM Zones WHERE ToolName = ? AND Zone = ?", Array As String(MyTool,MyzoneNum))
you also had missing single quotes for strings and double WHERE references