Wednesday, March 21, 2012

Problem with IDENT_CURRENT

I'm having a problem returning a value with IDENT_CURRENT:
When I run it through the Analyzer it's OK, when I run it through my ASP
code, I get a casting error on my web application. (Depending on the sql
transaction method I use, I sometimes get a -1 value (when using
ExecuteNon query) instead of the casting error(when using execute
Scalar))
here's the code:
CREATE PROCEDURE spSelectOrderID
AS SELECT IDENT_CURRENT('tbOrder') + 1
GO
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!"Patrick Delifer" <deliferp@.videotron.ca> wrote in message
news:e5fCqMDJFHA.2396@.TK2MSFTNGP12.phx.gbl...
> I'm having a problem returning a value with IDENT_CURRENT:
> When I run it through the Analyzer it's OK, when I run it through my ASP
> code, I get a casting error on my web application. (Depending on the sql
> transaction method I use, I sometimes get a -1 value (when using
> ExecuteNon query) instead of the casting error(when using execute
> Scalar))
> here's the code:
> CREATE PROCEDURE spSelectOrderID
> AS SELECT IDENT_CURRENT('tbOrder') + 1
> GO
>
Back up. You appear to be under the impression that this is a viable method
to prefetch an IDENTITY value for an upcoming insert into tbOrder. It's
not.
David

No comments:

Post a Comment