急救:这样在ASP中取得存储过程的结果集正确否?

icehell 2004-07-16 10:34:24
写法如下:
------------------------------
dim rs,sql
sql="sp_index " & id
set rs=conn.Execute(sql) ------取得执行存储过程的结果集
if (rs.bof and rs.eof) then ------判断结果集是否为空
response.write "error!"
else
response.write id
end if
------------------------------
但结果是错误的,为什么?
...全文
107 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
navana 2004-07-18
  • 打赏
  • 举报
回复
'.' 附近有语法错误==>一般都是字段类型的问题了
zjcxc 元老 2004-07-16
  • 打赏
  • 举报
回复
'你的id是什么值?

'这样呢?
sql="exec sp_index '" & id & "')

出错的语句(行67 ),是否是 set rs=conn.Execute(sql) 这条?
icehell 2004-07-16
  • 打赏
  • 举报
回复
列名倒不是很重要,我最想要的是判断结果集是否为空,如果为空则执行一个语句,如果不为空则执行另一个语句,与列名没有关系。
错误提示如下:
Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft OLE DB Provider for SQL Server 错误 '80040e14'

第 1 行: '.' 附近有语法错误。

/inc/conn.asp,行67
zjcxc 元老 2004-07-16
  • 打赏
  • 举报
回复
存储过程没错

你这样的存储过程,列名是x,而不是id,所以你调用的时候,也要用列名x
response.write rs("id")
改为:
response.write rs("x")


还有你的错误提示是什么?
icehell 2004-07-16
  • 打赏
  • 举报
回复
存储过程如下:
-------------------------------------
create proc sp_index
@a nvarchar(100)
as
select x from table
where x=@a

GO
-------------------------------------
存储过程应该没错吧?
在分析中测试也是没有问题的
zjcxc 元老 2004-07-16
  • 打赏
  • 举报
回复
错误提示是什么?

你的存储过程在查询分析器中能测试通过吗?
icehell 2004-07-16
  • 打赏
  • 举报
回复
这样还是不行
zjcxc 元老 2004-07-16
  • 打赏
  • 举报
回复
dim rs,sql
sql="exec sp_index " & id
set rs=server.createobject("adodb.recordset")
set rs=conn.Execute(sql) ------取得执行存储过程的结果集
if (rs.bof and rs.eof) then ------判断结果集是否为空
response.write "error!"
else
response.write rs("id")
end if

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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