2010-06-30 114 views
0

感谢dretzlaff17的回答,没有返回记录在记录(VB6)

我giveing细节..........从SQL Server

SP 2005不返回recordSet(VB6)记录中的记录返回-1。如果使用查询和记录集访问记录,记录集将填充记录。

使用相同的连接字符串。我检查得当,在VB6中为命令对象编写的代码没有问题,那么错在哪里?

有什么别的东西,我们必须在访问SQL Server的做2005

我的代码是这样

Dim Conn as new ADODB.Connection 

Dim RS as new ADODB.RecordSet 

Dim CMD as new ADODB.Command 

Conn.Open "Connection String" ' Its working 

CMD.ActiveConnection = Conn 

CMD.CommandType = adCmdStoredProc 

CMD.CommandText = "SPName" 

Set RS = CMD.Execute 

Debug.Print RS.RecordCount ' /* here result is -1 means CMD is not executing and RS is not filling with records */ 

and if use 

RS.Open "Select query", conn 'then this record set is filling with records. 

我也通过RS(光标)位置值设置为客户端检查和SP很简单,只有选择查询出现在SP no中的I/O参数中。

还有一件东西记录存在数据库表中不是空的。

这个您的想法讨好

感谢

回答

0

你能告诉你存储过程的文本? VB6是旧的东西,可能你只需要把

set nocount on 

开头的程序或打开可能连接后,即使执行这个作为查询。 如果它不能帮助简化试图存储过程的东西肯定是像 工作创建存储过程作为

set nocount on 
select 1 
1

RS.RecordCount'/ *此处的结果是-1 意味着CMD不执行和RS是 未填满记录

不,它不包含:它表示默认游标类型不支持RecordCount属性。

由于内容的更好的测试,请尝试:

Debug.Print RS.GetString 
0

如果你想记录计数,它通常是最好这样做:

set RS = new ADODB.Recordset 
RS.Open cmd, , adOpenDynamic, adLockReadOnly 
If Not RS.EOF then Debug.Print RS.RecordCount 
RS.Close