[thelist] Using @@Identity

Casey aspnet at thecrookstons.com
Tue Aug 23 23:26:59 CDT 2005

----- Original Message ----- 
From: "Ken Schaefer"


Well then.  I'm so glad to see you waited to respond until you're temper
could not be contained.  We, the little people beg your forgiveness and
grovel at the feet of your knowledge.

> a) use Scope_Identity not @@IDENTITY. Books Online tells you why, but
> basically if you have a trigger on a table that does an insert into
> table, then @@IDENTITY will return the identity in this second table
> than the table you just inserted into. Scope_Identity insulates you from
> problem

As stated in multiple previous posts, I was already aware of this.  But
thanks for the reminder.

> b) I would recommend against what Joshua has suggested. It might make
> in the CF world, but in ASP/ASP.NET you should return an output parameter
> (which is very lightweight), or use ExecuteScalar if you really want to
> return a recordset. ExecuteScalar is useful if you only want to return a
> recordset with a single row and a single column. I would recommend using
> Output Parameter

This is the first thing you have said in you're most gracious post that has
been helpful.

> As for how to do this, I'm 99% certain there is a code sample in ASP.NET
> Unleashed.

You may be right.  But I was not able to find it in any of the 1,459 pages.
Yes, I tried the index. Yes, I tried the Table of Contents.

> There's also google. I suggest you look there first - it will save
> you a lot of frustration.

Gee. Guess what, I did.  I found lots of very general advice, much like what
this list offers most of the time.

> Additionally, check out the lists here: www.aspadvice.com lots of good
> to answer ADO.NET and ASP.NET questions.

Good people.  You mean like your self?  Thanks for the tip, I think I may
check it out in hopes thet "good" people at www.aspadvice.com don't loose
their temper when someone asks a few questions.

>[code sample sniped]

All sarcasm aside, I do appreciate the help.  I'll chew on the sample you
provided. And now a note from the soap box....

Yes, I am less experienced then many of the people on this list.  Yes, I ask
a lot of questions. Yes, I DO actually try and find the answers on my own
before coming to this list, despite what you may think.  I don't expect much
when I post questions... in fact I would say 75% of the time nobody answers
them anyway. But, from time to time, a point in the right direction would be
nice, along with some patience for someone who is not as far a long as you
might be.

> Cheers

But just not too much of it.

> Ken

More information about the thelist mailing list