Home
Options

Accesing stored procedure value using output parameter

edited July 2012
I have a database that has a stored procedure to fetch a new key for a specified table. Essentially it takes a table name as input parameter, an output parameter for the key value. It grabs the current value for the key and stashes it, then increments the key value, returning the stashed key value.

Procedure [dbo].[GetNextID]
@TableName Varchar(45),
@KeyID Int OutPut

LinQPad sees the stored proc and it thinks the format should be:
ReturnDataSet TypedDataContext.GetNextID(string TableName, int? KeyID)

It should in fact according to all the docs I have read accept the output value as a reference.

int Key = 0;
GetNextID("Customer",ref Key); // LINQpad will not accept this

Instead it insists on the format
int? Key = 0;
GetNextID("Customer",Key);
Console.Writeline("New Key = " + Key). // results in "New Key = 0"

This executes, but I get no valid Key back - Key remains at 0 (of course it would). The value in teh database is incremented as expected of the stored proc.

Any ideas what's going on here? Running the beta 4.42.05

Comments

Sign In or Register to comment.