关于asp中的数据库查询问题!

来源:百度知道 编辑:UC知道 时间:2024/05/04 04:04:32
我的代码是这样的:
dim strdsn,strselectsql
set rs=server.CreateObject("adodb.recordset")
strselectsql="select * from article where articleid="&request.QueryString("id")
rs.open strselectsql,conn,3,1
错误是:
错误类型:
Microsoft JET Database Engine (0x80040E14)
语法错误 (操作符丢失) 在查询表达式 'articleid=' 中。
/readarticle.asp, 第 16 行
请高手指教

如果articleid 是数字就
strselectsql="select * from article where articleid="&request.QueryString("id")

如果如果articleid 是字符
strselectsql="select * from article where articleid='"&request.QueryString("id")&"'"

在rs.open strselectsql,conn,3,1语句前加上response.write strselectsql这个语句,也就是改成下面的样子:
dim strdsn,strselectsql
set rs=server.CreateObject("adodb.recordset")
strselectsql="select * from article where articleid="&request.QueryString("id")
response.write strselectsql
rs.open strselectsql,conn,3,1
然后,再重新测试一下,看看在错误提示(如下):

错误类型:
Microsoft JET Database Engine (0x80040E14)
语法错误 (操作符丢失) 在查询表达式 'articleid=' 中。
/readarticle.asp, 第 17 行

前面的查询语句是什么样的?
如果语句是:
select * from article where articleid=
则说明网页在提交时没有指定id的值,请检查提交页网页表单中的id项.

strselectsql="select * from article where articleid='&qu