我正在尝试获取等于我在文本框中输入的两个日期之间的数据! 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.Text
和txtEndDate.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)
答案 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