“标准表达式中的数据类型不匹配”

时间:2015-06-17 06:20:41

标签: sql vb.net ms-access-2010

我正在尝试获取等于我在文本框中输入的两个日期之间的数据! PO_Date列是DateTime。当我将日期硬编码到select语句中时,它非常有效,例如PO_Date >= #12/6/2013 3:54:15 PM# AND PO_Date <= #1/1/2015 3:54:15 PM#包含DropDownList2。只有在我尝试实施txtStartDate.TexttxtEndDate.Text时才出现错误!非常感谢帮助!

oRs.Open("SELECT PO_Date, PO.Vendor FROM PO 
WHERE PO_Date >= '#" & TxtStartDate.Text & "00:00:00 AM""#' AND
PO_Date <= '#" & TxtEndDate.Text & "00:00:00 AM""#' 
AND Vendor Like '%" & DropDownList2.SelectedValue & "%'", oCnn)

1 个答案:

答案 0 :(得分:1)

可能你有错字,但你可以检查:

oRs.Open("SELECT PO_Date, PO.Vendor FROM PO 
WHERE PO_Date >= #" & TxtStartDate.Text & " 00:00:00 AM# AND
PO_Date <= #" & TxtEndDate.Text & " 00:00:00 AM# 
AND Vendor Like '%" & DropDownList2.SelectedValue & "%'", oCnn)
  • AM""#' => AM#
  • "00:00:00 => " 00:00:00