这是我的SQL查询:
IModel
答案 0 :(得分:4)
首先,您应该使用parameterized sql queries并且不要直接将查询值与查询结合起来。
然后,你的where子句不正确,你应该使用AND
或OR
而不是,
添加多个过滤器:
sql = "SELECT * From CaterTrans WHERE [delivtime_] = @Parameter1
AND [delivdate_] = @Paramater2";
答案 1 :(得分:1)
Annabeth Moore是完全正确的你应该使用参数,如果你没有,它会是这样的:
sql = "SELECT * From CaterTrans WHERE [delivtime_] = '" &
TextBox1.Text & "' and [delivdate_] = '" & DateTimePicker1.Text & "'"
在db2中这也可行
sql = "SELECT * From CaterTrans WHERE ([delivtime_], [delivdate_]) = ('"
& TextBox1.Text & "', '" & DateTimePicker1.Text & "')"
或来自Annabeth
sql = "SELECT * From CaterTrans WHERE ([delivtime_], [delivdate_]) = (@Parameter1, @Paramater2)";
因为db2支持元组。