开发者

In VB6 using a connection object OpenRecordset how do I open a sproc?

I'm trying to open a sproc in vb6, I can successfully open a sproc fine in as开发者_StackOverflow中文版p, but vb6 it is having problems opening up the stored procedure. Here is the code I'm trying:

     qryStr = "DECLARE  @return_value int EXEC  @return_value = [dbo].[spSproc]" 

it has no return parameters ... just a select * from orders in the sproc and it runs fine in sql.

Dim rs as ADODB.Recordset
Set rs = new ADODB.Recordset
rs = co.OpenRecordset(qryStr, dbOptimistic)

I don't have problems with opening up queries, but opening up sprocs seems to be the problem. This should be a read only and I'm not passing any parameters. thx


I figured it out, there are two recordset objects in VB6. One is

Dim rs as ADODB.Recordset

and the other is

Dim rs as Recordset

The second one which does not include the ADODB behaves like the Recordset in ASP. That way I can use my rs.open qryStr, connectionObject


Probably all you need to do is set the commandtype, but you might want to check out this article anyway: http://www.codeproject.com/KB/vbscript/simple_sp_vb6.aspx


I'm afraid I don't have access to VB6 to check this properly, but i think you just need to remove the 'Declare @return_value ' from your SQL string, so it reads:

qryStr = "EXEC spSproc"

Hope this does the trick for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜