Kevin,
Thanks! This works.
I'll look at creating a store proc and returning SCOPE_IDENTITY(), but from my testing, I always got the correct ID returned. The way I tested this was I had a VFP app insert records into this table while I ran my insert routine from .net.
Thanks for your help.
Jerry
>Jerry,
>
>As for the syntax, the following would work (and there are probably several ways to code this)...
>
>
>object oTemp = ocommand.ExecuteScalar();
>int count = int.Parse(oTemp.ToString());
>
>
>It appears you *can* make successive pass-through calls to INSERT and then SCOPE_IDENTITY for a single connection/task where you know you're the only person inserting into the table (maybe for a data conversion)...
>
>...but Bonnie's suggestion is still the better one, to wrap up the insertion and the call to scope_identity as a transaction within a stored proc, and have the stored proc return the scope_identity. That's the best approach.
>
>Kevin