cannot get a value from scope_identity after insert

In ASp i am doing this:

set objrs=objconn.execute("insert into cart (title) values ('something');select SCOPE_IDENTITY() as id;")

When I check objrs("ID") it returns blank.  Nothing.  This works fine access but not in SQL 2000.  I find that it seems to have something to do with it being in the second line of the SQL.  if I replace the scope_identity() with max(cartid) i get the same thing.  So the second line is not returning a value.

Running this in the query analyzer DOES return the value as expected.

Any ideas?
jglazer63Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

saoirse1916Commented:
Have you tried running this query as a stored procedure?  I seem to remember running into this a while back and setting up an SP fixed it.
0
jglazer63Author Commented:
I do not want to do this as a stored procedure.  I want to do this entirely with the ADO execute.  It needs to be very generic.
0
BrandonGalderisiCommented:
Or perhaps the "1 rows effected" by the insert (or subsequent triggers) is messing with it.


set objrs=objconn.execute("set nocount on; insert into cart (title) values ('something');select SCOPE_IDENTITY() as id;")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

BrandonGalderisiCommented:
Also, although I know you say you don't want a proc, but a proc is the BEST thing for DB processing.
0
saoirse1916Commented:
That's it -- SET NOCOUNT ON...I knew there was something I was missing.  Brandon's right on the money.
0
jglazer63Author Commented:
Perfect.  You got it.  Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.