Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Stored Procedure not returning ADO recordset

Author  Topic 

Utpal
Posting Yak Master

179 Posts

Posted - 2002-09-14 : 02:19:54
Hi everybody

I am using VB 6.0 - SQL Server 7.0. I have a stored procedure as follows:



CREATE PROCEDURE Purchase_Plan_Extract_Selection @part_nos Varchar(8000) AS

DECLARE @host_id Varchar(20), @ColumnLength TinyInt, @StrColumnLength Varchar(3), @Total SmallInt, @No SmallInt, @part_no Char(8),
@query Varchar(500)

SET @host_id = HOST_ID()

SELECT @ColumnLength = COL_LENGTH( 'Purchase_Plan_Output', 'part_no' )
SET @StrColumnLength = LTRIM( STR( @ColumnLength ) )

SET @Total = CEILING( 1.000 * LEN( @part_nos ) / @ColumnLength )

SET @No = 0

UPDATE Purchase_Plan_Output
SET include = ' '

WHILE @No < @Total
BEGIN

PRINT 'Went into Output loop'

SET @No = @No + 1

SET @part_no = SUBSTRING( @part_nos, ( ( @No - 1 ) * @ColumnLength ) + 1, @ColumnLength )

EXECUTE Purchase_Plan_Mark_Item @host_id, @part_no

END

SELECT * FROM Purchase_Plan_Output (NOLOCK) WHERE [host_id] = @host_id AND include IN ( 'Y', 'D' )

RETURN



I am using the following code in VB to extract an ADO recordset:



With rOutput
.CursorLocation = adUseClient
.Open "EXECUTE Purchase_Plan_Extract_Selection '9010A '", Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
Do Until .EOF
' Code for processing rows
.MoveNext
Loop
End With



But after executing the .Open method, the recordset is not opening. However, when I use:


.Open "SELECT * FROM Purchase_Plan_Output (NOLOCK) WHERE [host_id] = @host_id AND include IN ( 'Y', 'D' )", Conn, adOpenForwardOnly, adLockReadOnly, adCmdText


which is the SELECT statement of the SP, the recordset is opening. Please help me.


VyasKN
SQL Server MVP &amp; SQLTeam MVY

313 Posts

Posted - 2002-09-14 : 05:44:51
Use SET NOCOUNT ON at the beginning of your stored procedure. For example:

CREATE PROCEDURE Purchase_Plan_Extract_Selection @part_nos Varchar(8000) AS
BEGIN
SET NOCOUNT ON
/* Rest of your code here */
END

--
HTH,
Vyas
http://vyaskn.tripod.com
Go to Top of Page

Utpal
Posting Yak Master

179 Posts

Posted - 2002-09-14 : 06:24:57
Thanks VyasKN ! That worked.


Go to Top of Page
   

- Advertisement -