静静在线等:郁闷一个下午的 select语句

SysPlus 2004-11-21 02:12:20
dim types
types=request.QueryString("typ")
/*typ来自另一个xx。asp:<a href="classify.asp?typ=文学书籍"></a>*/
....
rs.open"select * from books where remaincount<>0 and typ='"&types&"' order by book_id DESC",cn,3
/*其中books为表remaincount,types,book_id为其中的列*/
当加入typ='"&types&"'后就出问题

...全文
372 28 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangdatou 2004-11-22
  • 打赏
  • 举报
回复
看着我都郁闷!
wwg_yuyin 2004-11-22
  • 打赏
  • 举报
回复
问题解决了 我就不纳了闷了
为什么 “typ改成types试试!”(宇子) 就可以了呢?
我臆测:typ是我定义的一个变量,用来存放request.QueryString("typ")传来的值,叫types或是其他的怎么就不可以呢?其原由如何啊!(术语有问题敬请勘正。)
请指教。
-----------------------------------
typ是你自己定义的变量,而types则是你数据表的里字段名,在sql语句里,象:select * from books where remaincount<>0 and typ='"&types&"' order by book_id DESC,中的typ应是字段名,而其中的types则应是变量,把这句话改成:select * from books where remaincount<>0 and types='"&types&"' order by book_id DESC,虽然里面有两个types,但两个是不一样的,前一个是数据库里的固定的字段名,而后者则是你通过dim types
types=request.QueryString("typ")得来的变量
gxh973121 2004-11-22
  • 打赏
  • 举报
回复
写法很简单,自己找一下,另不推荐这样写 ,安全漏洞
lwlmaomao 2004-11-22
  • 打赏
  • 举报
回复
用response.write把sql打印出来,然后再到查询分析器运行试试。
iscandy 2004-11-22
  • 打赏
  • 举报
回复

根本没有什么大问题。

rs.open 之前 加一个 response.write sql ,然后拿到 数据库管理器中执行看看

zhuangjunx 2004-11-22
  • 打赏
  • 举报
回复
up
91jk 2004-11-22
  • 打赏
  • 举报
回复
dim types
types=request.QueryString("typ")

你已经把值赋给TYPES了
SysPlus 2004-11-22
  • 打赏
  • 举报
回复
问题解决了 我就不纳了闷了
为什么 “typ改成types试试!”(宇子) 就可以了呢?
我臆测:typ是我定义的一个变量,用来存放request.QueryString("typ")传来的值,叫types或是其他的怎么就不可以呢?其原由如何啊!(术语有问题敬请勘正。)
请指教。
fhsoft8508539 2004-11-21
  • 打赏
  • 举报
回复
先用个固定数值去测试,然后再用变量
poron9 2004-11-21
  • 打赏
  • 举报
回复
同意楼上的。
wwg_yuyin 2004-11-21
  • 打赏
  • 举报
回复
重复一次,你表里的字段是:remaincount,types,book_id,没有typ!,所以把rs.open"select * from books where remaincount<>0 and typ='" & types & "' order by book_id DESC",cn,1,1
中的typ改成types试试!
wwg_yuyin 2004-11-21
  • 打赏
  • 举报
回复
第20行:rs.open"select * from books where remaincount<>0 and typ='" & types & "' order by book_id DESC",cn,1,1
加上 typ='" & types & "' 就出问题!!

----------------------------------------------------
注意到:typ='"&types&"'这里没有,你表里根本没有typ,当然会出错了,你确定你把typ改成types了吗??
datamoon 2004-11-21
  • 打赏
  • 举报
回复
做个判断看types 是否有值。 (typ='"&types&"')加个括号试试

RESPONSE.WRITE * 打印检查。
SysPlus 2004-11-21
  • 打赏
  • 举报
回复
回复人: timdy() ( ) 信誉:100
rs.open"select * from books where remaincount<>0 and types='"&types&"' order by book_id DESC",cn,3,1
大哥用你的代码过了!!!!!!!但是我的
rs.open"select * from books where remaincount<>0 and typ='"&types&"' order by book_id DESC",cn,3,1咋就过不去呢!一个变量叫types和typ有什么区别呢!
我用 typ=request.QueryString("typ")
--------------------------------
又出现的问题是
再加上<%= rs("book_id") %>出现了错误!!
多谢多谢
ruyunluck 2004-11-21
  • 打赏
  • 举报
回复
先用RESPONSE.WRITE TYPE 检查一下
用SQL="select * from books where remaincount <>0 and types= '"&types&"' order by book_id DESC"
再用RESPONSE.WRITE SQL 检查一下
xyp730000 2004-11-21
  • 打赏
  • 举报
回复
rs.open "select * from books where remaincount <>0 and types= '"&types&"' order by book_id DESC",conn,3
SysPlus 2004-11-21
  • 打赏
  • 举报
回复
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
/classify.asp, 第 20 行
浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
页:
GET /classify.asp
----------------------------
第20行:rs.open"select * from books where remaincount<>0 and typ='" & types & "' order by book_id DESC",cn,1,1
加上 typ='" & types & "' 就出问题!!
timdy 2004-11-21
  • 打赏
  • 举报
回复
rs.open"select * from books where remaincount<>0 and types='"&types&"' order by book_id DESC",cn,3,1

timdy 2004-11-21
  • 打赏
  • 举报
回复
有两个错误:
1、type是数据库关键字,不能用TTOE作为列名。
2、TYPE
3、TYPE是数值型,也可能出现错误,这样表示'"&type&"'字符串型。
David2008 2004-11-21
  • 打赏
  • 举报
回复
rs.open sql,conn,1,1
看是不是参数错了
加载更多回复(8)

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧