本文介绍了数据库查询未正确执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我执行此查询时,如果我在使用tbl_permits`.company时正在搜索`tbl_permits`.bid`但它起作用,它说未知列"我正在搜索的内容来自此qoutes"
When i excute this query it works if am searching for `tbl_permits`.`bid` BUT when i use tbl_permits`.`company` it says Unknown column "whatever i was searching comes here in this qoutes"
"SELECT * FROM `tbl_permits` WHERE `tbl_permits`.`bid`=" & txtSearch.Text & " OR `tbl_permits`.`company`=" & txtSearch.Text & ";"
在此先感谢
thanks in advance
推荐答案
"SELECT * FROM tbl_permits WHERE tbl_permits.bid='" & txtSearch.Text & "' OR tbl_permits.company='" & txtSearch.Text & "'"
您缺少传递给查询的searchtext值周围的单引号.
此外,我建议您使用参数化查询".它会克服很多问题,并且是一种更干净,更安全的执行查询的方法.
更新:您应该使用参数化查询 [ ^ ]和命令一起使用.
You were missing the single quotes around the searchtext values passed to query.
Further, I would suggest you to use ''parametrized query''. It will overcome lots of issues and is much cleaner and safer way to execute queries.
UPDATE: You should use parameterized query[^] with your command.
这篇关于数据库查询未正确执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!