注册 登录
编程论坛 ASP技术论坛

[求助]数据类型问题

可见光 发布于 2007-08-23 12:36, 407 次点击
错误类型:
Microsoft JET Database Engine (0x80040E07)
标准表达式中数据类型不匹配。
/eshop.asp, 第 34 行

<%
strCpbm=request("cpbm")
ProductList=session("ProductList")
Products=Split(request("cpbm"),",")
for I=0 to UBound(Products)
PutToShopBag Products(I),ProductList
Next
session("ProductList")=ProductList
Head="以下是你所选购的CD"
ProductList=session("ProductList")
if len(ProductList)=0 then
response.redirect"nothing.asp"
response.End
end if
if request("MySelf")="Yes" then
ProductList=""
Products=split(request("cpbm"),",")
for I=0 to UBound(Products)
PutToShopBag Products(I),ProductList
Next
session("ProductList")=ProductList
end if
if len(ProductList)=0 then
response.redirect"nothing.asp"
response.End
end if
set rs=server.CreateObject("adodb.recordset")
sql="Select * From product"
sql=sql &" Where Product_Id In("&ProductList&")"
rs.open sql,conn,3,3 '报错位置
%>

我的Product_Id字段的数据类型是自动编号

如果是文本的就不会报错。。
但这个地方我需要那个字段是自动编号。。大家能不能帮我想想办法

[此贴子已经被作者于2007-8-23 12:54:49编辑过]

3 回复
#2
ayue2222007-08-23 13:10
set rs=server.CreateObject("adodb.recordset")
sql="Select * From product"
sql=sql &" Where Product_Id In("&ProductList&")"

response.write sql:response.end //这里查看一下执行的SQL 语句有没有错..

rs.open sql,conn,3,3 '报错位置
#3
可见光2007-08-23 13:22
Select * From product Where Product_Id In('1','2','4')
上面时执行后的结果

我以前Product_Id不是自动编号的,很征程的。现在把以前的自动编号的给删了 换成了Product_Id, 就报错
#4
ayue2222007-08-23 14:09
这里最简单的方法就是 ..
在数据库查询之前加上一条 ProductList=replace(ProductList,"'","")
但是这是治标不治本的方法 ..... 关键是在request("cpbm") ,你现在传来的数组应该是('1','2','3')这样的而不是(1,2,3)这样 ...
1