大家帮忙看一下这个sql构造怎么老报错 急用!!!!!!!!!!!!

princekey 2004-08-09 04:57:42
str1 = "select * from stair where 1=3 and "
str2 = "(name like '"&searchkey&"'"
str3 = " and wuye like '"&wuye&"'"
str4 = " and price>"&price1&" and price=<"&price2&")"
sql = str1&str2&str3&str4
set rs=conn.Execute(sql)
大家帮忙看一下这个sql构造怎么老报错
错误类型:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
/tool/lookbuilding/sousuo.asp, 第 42 行
42 行:set rs=conn.Execute(sql)
急等谢谢 各位大虾 要不今天的任务又没有完成!!!!!!!!!!!!
...全文
108 16 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
一个老程序袁 2004-08-09
  • 打赏
  • 举报
回复
avg_price=<2500 ??
=>
avg_price<=2500
princekey 2004-08-09
  • 打赏
  • 举报
回复
哈哈 搞定谢谢 加分
61 2004-08-09
  • 打赏
  • 举报
回复
sql = "select * from stair where 1=3 and name like '"&searchkey&"' and wuye like '"&wuye&"' and (price between "&price1&" and "&price2&")"
set rs=server.CreateObject ("adodb.recordset")
on error resume next
rs.Open sql,Conn,1,3
response.write err.description
lbd8848 2004-08-09
  • 打赏
  • 举报
回复
那在sqlserver的"查询分析器"能不能执行?
princekey 2004-08-09
  • 打赏
  • 举报
回复
不可以 哎 晕
lbd8848 2004-08-09
  • 打赏
  • 举报
回复
name -> [name] 试试
princekey 2004-08-09
  • 打赏
  • 举报
回复
我现在
response.write aql
得到的是select * from stair where name like '国' and wuye like '高档公寓' and avg_price>2000 and avg_price=<2500
但还是同样的错误
lbd8848 2004-08-09
  • 打赏
  • 举报
回复
1.where 1=3 ?? 做什么用 1是不是l(L) ?
2.既然条件间都用and 连接那()有什么作用?

princekey 2004-08-09
  • 打赏
  • 举报
回复
不可以 啊 prince是数字int
lbd8848 2004-08-09
  • 打赏
  • 举报
回复
那问题,还是在sql语句上,price是什么类型
这样试试:
str1 = "select * from stair where 1=3 and "
str2 = "(name like '%"&searchkey&"%'"
str3 = " and wuye like '%"&wuye&"%'"
str4 = " and price>"&price1&" and price=<"&price2&")"
OnlyVB 2004-08-09
  • 打赏
  • 举报
回复
改成:
str2 = "(name like '%"&searchkey&"%'"
str3 = " and wuye like '%"&wuye&"%'"
princekey 2004-08-09
  • 打赏
  • 举报
回复
rs.open "select * from stair",conn,1,1
可是我打开这个就好的
baby21st 2004-08-09
  • 打赏
  • 举报
回复
str2 = "(name like '"&searchkey&"'"
--------^
str4 = " and price>"&price1&" and price=<"&price2&")"
---------------------------------------------------^

把这()去掉看看
lbd8848 2004-08-09
  • 打赏
  • 举报
回复
再试一下语句能否在sqlserver的"查询分析器"执行
如果可以,那问题就出在conn上了
princekey 2004-08-09
  • 打赏
  • 举报
回复
都是正确的
lbd8848 2004-08-09
  • 打赏
  • 举报
回复
使用
response.write sql
显示出来看看
字段名是否正确
price1,price2是否为空??

28,409

社区成员

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

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