I am using the SqlHelper class from the Microsoft Data Application Block and
had a question about returning an Identity Column.

Basically, I have a form with a grid bound to a DataSet. The user can, for
example, Add a new record. When they do this, and press Save, I call the
ExecuteDataSet method. I am using Stored Procedures, and in the procedure,
at the end of the insert, I do the following:

select @id = scope_identity()

@id is set as an OUTPUT parameter on the procedure.

When I check the value of the @id column on the dataset that gets returned,
the value is null.

I am just wondering if I am doing this correctly. I will continue to debug
the code, but thought I would see if anybody else has done this
successfully.

THanks,

Mark

Re: Data Access Block and Identity Column Return... by Mark

Mark
Tue Jul 27 09:45:35 CDT 2004

Never mind....it was an interface problem between the seat and the keyboard!
I was not setting the Parameter direction correctly on my output parameter,
and it defaults to INPUT, so the value was coming back Null.

Mark

"Mark Essex" <messex@nospam.netalytics.com> wrote in message
news:OG1zB09cEHA.1672@TK2MSFTNGP12.phx.gbl...
> I am using the SqlHelper class from the Microsoft Data Application Block
and
> had a question about returning an Identity Column.
>
> Basically, I have a form with a grid bound to a DataSet. The user can,
for
> example, Add a new record. When they do this, and press Save, I call the
> ExecuteDataSet method. I am using Stored Procedures, and in the
procedure,
> at the end of the insert, I do the following:
>
> select @id = scope_identity()
>
> @id is set as an OUTPUT parameter on the procedure.
>
> When I check the value of the @id column on the dataset that gets
returned,
> the value is null.
>
> I am just wondering if I am doing this correctly. I will continue to
debug
> the code, but thought I would see if anybody else has done this
> successfully.
>
> THanks,
>
> Mark
>
>
>
>