Re: Retrieving a BigInt out parameter from a Stored Procedure



There are a couple of tricks when working with returned values.
a.. There is no need to set the Size property for any int types.
b.. Make sure to retrieve all rowsets before trying to fetch (or even address) the output parameters.
hth


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Eddie Lascu" <EddieLascu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:2FF3AFFE-2529-4029-9F8F-C022BC327F80@xxxxxxxxxxxxxxxx
Hello everybody,

I've struggling with this issue for a few days now, and the resources on the
Internet are not very helpful. I have a SQL Server database and some of the
stored procedures return unique Id for the records I create. The unique Ids
are declared as BigInt, which is a 64-bit integer. I am having problems
retrieving this parameter within my application. I use EntLib and here is the
sequence:

// objDatabase and objDbCommand are object previously initialized
// add the output parameter -> unique Id
this.objDatabase_.AddOutParameter(objDbCommand, "@unique_id",
SqlDbType.BigInt, sizeof(Int64));

// instead of SqlDbType.BigInt I also tried UInt64 and Int64

// <snip>

// retrieve the output parameter
Int64 nUniqueId = (Int64)objDatabase_.GetParameterValue(objDbCommand,
"@unique_id");

The thing is that the output parameters returns as NULL and that cannot be
cast to any of the types I am trying to use to retrieve the unique Id created
by the database. I can see that the field is created in the table, so the
stored procedure is doing its job.

I remember Shawn Wildermuth, our ADO Guy used to post here, from time to
time. Maybe he can shed some light, but anyone else is welcome to post
comments.

Thanks for you