Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

error while calling Stored Procedure from OleDB

2 views
Skip to first unread message

vijay singh

unread,
Aug 26, 2009, 1:30:01 PM8/26/09
to
Platform : VC++(Visual Studio 2008), Windows 2003 server,

Technology :OleDb

Database : SQL Server

Provider : SQLOLEDB

Hi,

I have developed a stored procedure which open a record set for a given SQL
and return records count as output parameter. After procedure call returned
count from this stored procedure is zero.

ALTER PROCEDURE [dbo].[ABI_SP_OPENRECORDSETANDCOUNT]
( @strOpenSQL NVARCHAR(2000), @nCount nvarchar(20) OUTPUT )

AS

BEGIN

SET NOCOUNT ON;
EXECUTE sp_executesql @strOpenSQL;
set @nCount = @@rowcount;

END

I am using OleDB to access database and calling this procedure using
CDynamicParameterAccessor accessor. Using same accessor I am successfully
able to open record set and get count using Oracle database but for SQL
Server returned count is zero.

Please help me resolve this issue.

Thanks in advance

Vijay


Erland Sommarskog

unread,
Aug 26, 2009, 5:28:26 PM8/26/09
to
vijay singh (vijay...@abosoftware.com) writes:
> I have developed a stored procedure which open a record set for a given
> SQL and return records count as output parameter. After procedure call
> returned count from this stored procedure is zero.
>
>
> ALTER PROCEDURE [dbo].[ABI_SP_OPENRECORDSETANDCOUNT]
> ( @strOpenSQL NVARCHAR(2000), @nCount nvarchar(20) OUTPUT )

nvarchar(20)?



> SET NOCOUNT ON;
> EXECUTE sp_executesql @strOpenSQL;
> set @nCount = @@rowcount;

Does @strOpenSQL produce a result set? In that case you need to get
past that result set before you can get the parameter values. Use
IMultipleResults to go through the result sets.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

0 new messages