asp 变量查询出错

来源:百度知道 编辑:UC知道 时间:2024/05/29 01:36:32
booksql="select book_name,book_message,book_id,book_date from message where book_show=true and book_date=#2009-8-12#order by book_date desc"
set brs=server.CreateObject("adodb.recordset")
brs.open booksql,conn,1,1

查询的一段代码,用常量正确,如果改成变量
booksql="select book_name,book_message,book_id,book_date from message where book_show=true and book_date=#"&data&"#order by book_date desc"
第一次出现页面正确,页面中有一文本框和按钮,在文本框中输入页数跳转到相应页面,单击按钮出错,报brs.open booksql,conn,1,1ODBC 驱动程序不支持所需的属性。
booksql="select book_name,book_message,book_id,book_date from message where book_show=true and book_date=#"&FormatDateTime(data)&"#order by book_date desc"
set brs=server.CreateObject("adodb.recordset")
还是,从调用页过来能够正确显示,因为记录数多做了分页显示,单击跳转说FormatDateTime类型不匹配


book_date=#"&data&"#
换这个试试
DATEDIFF(day,book_date,'"&data&"' )=0

把 #换成 "' 和 '"看看

ACCESS用#才是正确的... order前要空格..不知道你有没有

你的data的格式有错误吗?
数据库字段book_date 与 变量data的数据格式是不是一样的呢?
如果不一样就会出现错误了。