你怎么什么都用LIKE语法呢?
日期型:
  Access:FindStr="Select * from card where ordtime=#" & txtName & "#"
  MySQL/MS SQL:FindStr="Select * from card where ordtime='" & txtName & "'"长整型:
  FindStr = "select * from card where ID=" & txtName

解决方案 »

  1.   

    用等号就可以了,除非你想模糊查找。
    对于日期型,FindStr = "select * from card where ordtime like "'" & txtName & "'",这里的ordtime要是date类型的字段,然后,txtName应该用CDate进行转换,被查询的日期应该用#号括起来,如下:FindStr = "select * from card where ordtime=#" & CDate(txtName) & "#"
    对于另外一个问题,因为没有对txtName进行类型转换,所以出错,应该:FindStr = "select * from card where ID=" & CLng(Val(txtName)),注意其中对数值字段进行查询时,你的CLng(Val(txtName))两边不要加单引号(')