Home All Groups Group Topic Archive Search About

Using Stored Procedure at sqlDataAdapters with output parameters

Author
28 Feb 2006 9:13 AM
Esref DURNA
declare @Count int

select @Count = COUNT ( * ) FROM tblXUDUserShip

select FirstName,SurName,@Count AS BankaSayisi FROM tblXUDUserShip



I have a Stored Procedure Which Ends with these returns.

I Create a SqlDataAdapter with a sqlcommand with type stored procedure

I m using this SqlDataAdapter as like .Fill(DataSet);

How I Coult get The Output parameter "Count" from this adaptor when it is
Filling the dataset?

Author
28 Feb 2006 4:20 PM
William (Bill) Vaughn
You must create an OUTPUT parameter in the SelectCommand.Parameters
collection. It can be captured once the Fill is executed.
Actually, for this SQL I would probably not use a Fill because this does not
return a rowset. I would use a scalar, code the TSQL like this

select  COUNT ( * ) FROM tblXUDUserShip

and use the ExecuteScalar method to return the value.

This is explained in my book "ADO and ADO.NET Examples and Best Practices".

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Esref DURNA" <esref_du***@microsoft.com> wrote in message
news:%233ahKdEPGHA.3840@TK2MSFTNGP14.phx.gbl...
> declare @Count int
>
> >
> select FirstName,SurName,@Count AS BankaSayisi FROM tblXUDUserShip
>
>
>
> I have a Stored Procedure Which Ends with these returns.
>
> I Create a SqlDataAdapter with a sqlcommand with type stored procedure
>
> I m using this SqlDataAdapter as like .Fill(DataSet);
>
> How I Coult get The Output parameter "Count" from this adaptor when it is
> Filling the dataset?
>
>
>
>

AddThis Social Bookmark Button