您的位置:首页 > 数据库

SqlServer ado连接 调用存储过程出 0x80020009 错

2010-05-28 09:55 183 查看
@database = Sequel.ado(:conn_string=>conn, :provider=>"SQLNCLI10")

@database.fetch "select * from Peopel.dbo.Hello"

@database.run "exec Peopel.dbo.getmsg;"

出现 下面错误

OLE error code:800A0E78 in ADODB.Recordset

Operation is not allowed when the object is closed.
HRESULT error code:0x80020009

在存储过程前加上 Set Nocount ON; 就可以了。

@database.run "Set Nocount ON; exec Peopel.dbo.getmsg;"

或者在存储过程的定义里的,开始处加上 set nocount on; procedure ....; set nocount off. 这样也可以优化存储过程的速度。

set nocount on 会关闭 Transact-SQL 语句中的 affect rows 输出, 当存储过程有多个select 或 insert, update 语句时, affect rows 会影响ado 的 dataset。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: