VB中 日期控件查询时遇到问题
sql = "select * from 收费信息表 where 缴费日期 between #" & DTPicker1.Value & "# and #" & DTPicker2.Value & "#"
rs_shoufei.CursorLocation = adUseClient
rs_shoufei.Open sql, conn, adOpenKeyset, adLockPessimistic '这一行是黄色的
Set DataGrid1.DataSource = rs_shoufei
错误如下描述:
实时错误‘-2147217900(80040e14)’
[Microsoft][ODBC SQL Driver][SQL Server]第1行:
'#'附近有语法错误。
[解决办法]
这样试试:
sql = "select * from 收费信息表 where 缴费日期 between '" & DTPicker1.Value & "' and '" & DTPicker2.Value & "'"