asp中读取数据库的文本值

来源:百度知道 编辑:UC知道 时间:2024/04/27 04:48:46
Request.QueryString("id")
是文本

select * from 商品 where 品牌="&Request.QueryString("id")&" order by 编号 desc

无法显示数据
不行呀!!!

Request.QueryString("id") 显示数值为 联想

select * from 商品 where 品牌="&Request.QueryString("id")&" order by 编号 desc
也可一写成下面这样
select * from 商品 where 品牌=联想 order by 编号 desc

但是他提示无记录!!!数据库里绝对有!
这是为什么呀?

SQL语句错了
如果你用VBS做ASP,则是
strsql="select * from 商品 where 品牌=""" & Request.QueryString("id") & """ order by 编号 desc"
其中用""表示字符串的"
如果是用JS做ASP,则是
strsql="select * from 商品 where 品牌=\"" & Request.QueryString("id") & "\" order by 编号 desc"
其中用\"表示字符串中的"

此外两种都可这样写
strsql="select * from 商品 where 品牌='" & Request.QueryString("id") & "' order by 编号 desc"

去试试吧!
肯定好~
楼上好象不是ASP的~

select * from 商品 where 品牌='"&Request.QueryString("id")&"' order by 编号 desc

品牌这个字段是非INTEGER型的吧?
"&Request.QueryString("id")&" 的两旁边加单引号