Hi
I have a Stored Proc in SQL server, which creates a record key when a record
is created.

I want to return the value back to my code, once the record has been
created.

I am using SQLHelper (Data Application Blocks for SQLServer), and calling
the ExecuteNonQuery method in the SQLHelper class...

Does anyone have any sample code from their C# code, or T-SQL code to help??

Thanks


Paul

Re: SQLHeper ExecuteNonQuery - returning values by Teemu

Teemu
Thu Jan 27 01:35:46 CST 2005

Hi,

if you use ExecuteNonQuery, the way to return values is within output
parameters. In SQL documentation there are lots of about output parameters
however basically it is a proc parameter specified with OUTPUT keyword. For
example

CREATE PPROCEDURE myProc
...
@newid int OUTPUT
AS
...
/* set the value of the parameter somewhere here */

After the call to ExecuteNonQuery, this value is readable from the
SqlParameter given to the proc (which matches the @newid )

--
Teemu Keiski
ASP.NET MVP, Finland

"Paul Aspinall" <paul@aspy.co.uk> wrote in message
news:0kVJd.36195$2b6.13294@fe3.news.blueyonder.co.uk...
> Hi
> I have a Stored Proc in SQL server, which creates a record key when a
> record is created.
>
> I want to return the value back to my code, once the record has been
> created.
>
> I am using SQLHelper (Data Application Blocks for SQLServer), and calling
> the ExecuteNonQuery method in the SQLHelper class...
>
> Does anyone have any sample code from their C# code, or T-SQL code to
> help??
>
> Thanks
>
>
> Paul
>



Re: SQLHeper ExecuteNonQuery - returning values by Paul

Paul
Thu Jan 27 02:26:30 CST 2005

Hi - Thanks for the reply.

I am familiar with output parameters from T-SQL, however, I cannot seem to
return values specifically using the SQL Application Blocks (SQLHelper).

Does SQLHelper support output params?

Thanks


"Teemu Keiski" <joteke@aspalliance.com> wrote in message
news:%23bzERLEBFHA.2428@TK2MSFTNGP14.phx.gbl...
> Hi,
>
> if you use ExecuteNonQuery, the way to return values is within output
> parameters. In SQL documentation there are lots of about output parameters
> however basically it is a proc parameter specified with OUTPUT keyword.
> For example
>
> CREATE PPROCEDURE myProc
> ...
> @newid int OUTPUT
> AS
> ...
> /* set the value of the parameter somewhere here */
>
> After the call to ExecuteNonQuery, this value is readable from the
> SqlParameter given to the proc (which matches the @newid )
>
> --
> Teemu Keiski
> ASP.NET MVP, Finland
>
> "Paul Aspinall" <paul@aspy.co.uk> wrote in message
> news:0kVJd.36195$2b6.13294@fe3.news.blueyonder.co.uk...
>> Hi
>> I have a Stored Proc in SQL server, which creates a record key when a
>> record is created.
>>
>> I want to return the value back to my code, once the record has been
>> created.
>>
>> I am using SQLHelper (Data Application Blocks for SQLServer), and calling
>> the ExecuteNonQuery method in the SQLHelper class...
>>
>> Does anyone have any sample code from their C# code, or T-SQL code to
>> help??
>>
>> Thanks
>>
>>
>> Paul
>>
>
>



Re: SQLHeper ExecuteNonQuery - returning values by Ollie

Ollie
Thu Jan 27 03:23:21 CST 2005

try using the ExecuteScalar instead this is design to return a single value
from a database call

HTH

Ollie Riches

"Paul Aspinall" <paul@aspy.co.uk> wrote in message
news:WA1Kd.244436$Z7.425@fe2.news.blueyonder.co.uk...
> Hi - Thanks for the reply.
>
> I am familiar with output parameters from T-SQL, however, I cannot seem to
> return values specifically using the SQL Application Blocks (SQLHelper).
>
> Does SQLHelper support output params?
>
> Thanks
>
>
> "Teemu Keiski" <joteke@aspalliance.com> wrote in message
> news:%23bzERLEBFHA.2428@TK2MSFTNGP14.phx.gbl...
> > Hi,
> >
> > if you use ExecuteNonQuery, the way to return values is within output
> > parameters. In SQL documentation there are lots of about output
parameters
> > however basically it is a proc parameter specified with OUTPUT keyword.
> > For example
> >
> > CREATE PPROCEDURE myProc
> > ...
> > @newid int OUTPUT
> > AS
> > ...
> > /* set the value of the parameter somewhere here */
> >
> > After the call to ExecuteNonQuery, this value is readable from the
> > SqlParameter given to the proc (which matches the @newid )
> >
> > --
> > Teemu Keiski
> > ASP.NET MVP, Finland
> >
> > "Paul Aspinall" <paul@aspy.co.uk> wrote in message
> > news:0kVJd.36195$2b6.13294@fe3.news.blueyonder.co.uk...
> >> Hi
> >> I have a Stored Proc in SQL server, which creates a record key when a
> >> record is created.
> >>
> >> I want to return the value back to my code, once the record has been
> >> created.
> >>
> >> I am using SQLHelper (Data Application Blocks for SQLServer), and
calling
> >> the ExecuteNonQuery method in the SQLHelper class...
> >>
> >> Does anyone have any sample code from their C# code, or T-SQL code to
> >> help??
> >>
> >> Thanks
> >>
> >>
> >> Paul
> >>
> >
> >
>
>



Re: SQLHeper ExecuteNonQuery - returning values by Teemu

Teemu
Thu Jan 27 08:46:44 CST 2005

Yes it does, if you declare parameter objects for it explictly. Have you
tried this?

--
Teemu Keiski
ASP.NET MVP, Finland



"Paul Aspinall" <paul@aspy.co.uk> wrote in message
news:WA1Kd.244436$Z7.425@fe2.news.blueyonder.co.uk...
> Hi - Thanks for the reply.
>
> I am familiar with output parameters from T-SQL, however, I cannot seem to
> return values specifically using the SQL Application Blocks (SQLHelper).
>
> Does SQLHelper support output params?
>
> Thanks
>
>
> "Teemu Keiski" <joteke@aspalliance.com> wrote in message
> news:%23bzERLEBFHA.2428@TK2MSFTNGP14.phx.gbl...
>> Hi,
>>
>> if you use ExecuteNonQuery, the way to return values is within output
>> parameters. In SQL documentation there are lots of about output
>> parameters however basically it is a proc parameter specified with OUTPUT
>> keyword. For example
>>
>> CREATE PPROCEDURE myProc
>> ...
>> @newid int OUTPUT
>> AS
>> ...
>> /* set the value of the parameter somewhere here */
>>
>> After the call to ExecuteNonQuery, this value is readable from the
>> SqlParameter given to the proc (which matches the @newid )
>>
>> --
>> Teemu Keiski
>> ASP.NET MVP, Finland
>>
>> "Paul Aspinall" <paul@aspy.co.uk> wrote in message
>> news:0kVJd.36195$2b6.13294@fe3.news.blueyonder.co.uk...
>>> Hi
>>> I have a Stored Proc in SQL server, which creates a record key when a
>>> record is created.
>>>
>>> I want to return the value back to my code, once the record has been
>>> created.
>>>
>>> I am using SQLHelper (Data Application Blocks for SQLServer), and
>>> calling the ExecuteNonQuery method in the SQLHelper class...
>>>
>>> Does anyone have any sample code from their C# code, or T-SQL code to
>>> help??
>>>
>>> Thanks
>>>
>>>
>>> Paul
>>>
>>
>>
>
>



Re: SQLHeper ExecuteNonQuery - returning values by Havagan

Havagan
Thu Jan 27 08:47:03 CST 2005

Paul,

For SqlHelper.ExecuteNonQuery you need to first define your output
parameters in .NET, call .ExecuteNonQuery (passing it the parameter object),
then reference the .Value of the parameter after your stored procedure
executes.

Let me know if you need code posted.

Paul