否则ado会把受到影响的行数当作结果集。 这样也可以, set datagrid.datarsource=rec.nextrecordset
将存储过程改为:set nocount on select * into #temp1 from table1 select * from #temp1 set nocount off
老兄,你这方法我试了。不行啊。你看一下我写的程序: -----------------sql--------- SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO set nocount on gocreate PROC MyProc ASselect * into #temp1 from table1 select * from #temp1 returnGO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON goset nocount on go -----------------------vb------------------ vb代码 dim rec as recordset Set rec = New ADODB.Recordset rec.CursorLocation = adUseClient rec.Open "MyProc", Conn, adOpenStatic, adLockReadOnly If Rec.RecordCount = 0 Then MSHFlexgrid1.clear: MsgBox "没有您要的数据!!!": Exit Sub mshflexgrid1.datasource=rec请执行上面代码,实验。rec.open 后,下一句出错。存储过程在查询分析器里面执行没有错误。 加了 set nocount on go 后,vb里仍然和以前一样出错!
后面不要加return set nocount的位置也不对 -----------------sql--------- SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GOcreate PROC MyProc AS set nocount on --加在这里 select * into #temp1 from table1 select * from #temp1 --return --去掉此句 set nocount on --加在这里 GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON go
这样也可以,
set datagrid.datarsource=rec.nextrecordset
select * into #temp1 from table1
select * from #temp1
set nocount off
-----------------sql---------
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
set nocount on
gocreate PROC MyProc
ASselect * into #temp1 from table1
select * from #temp1
returnGO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
goset nocount on
go
-----------------------vb------------------
vb代码
dim rec as recordset
Set rec = New ADODB.Recordset
rec.CursorLocation = adUseClient
rec.Open "MyProc", Conn, adOpenStatic, adLockReadOnly
If Rec.RecordCount = 0 Then MSHFlexgrid1.clear: MsgBox "没有您要的数据!!!": Exit Sub
mshflexgrid1.datasource=rec请执行上面代码,实验。rec.open 后,下一句出错。存储过程在查询分析器里面执行没有错误。
加了
set nocount on
go
后,vb里仍然和以前一样出错!
set nocount的位置也不对
-----------------sql---------
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GOcreate PROC MyProc
AS
set nocount on --加在这里
select * into #temp1 from table1
select * from #temp1
--return --去掉此句
set nocount on --加在这里
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
go