D Declan Well-Known Member Licensed User Longtime User Nov 13, 2015 #1 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. Code: Copy 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
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. Code: Copy 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
S sorex Expert Licensed User Longtime User Nov 13, 2015 #2 I think you are confusing two things. you either concatenate the value OR use the array method and use a ? where the value should be. Code: Copy 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 Upvote 0
I think you are confusing two things. you either concatenate the value OR use the array method and use a ? where the value should be. Code: Copy 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