@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。