Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need @@identity in an ASP

Posted on 1998-10-07
4
Medium Priority
?
206 Views
Last Modified: 2010-03-19
I execute a query that reads:
INSERT INTO table (field1, field2) VALUES (2,2)
   SELECT @@identity as ident
If I do that in the Interdev data environment, it returns a table with one column labeled "ident" and the value of the identity field just assigned. When I do the same thing in my ASP then try to access the recordset("ident"), I get "invalid procedure on closed object". Any ideas?
0
Comment
Question by:rickpaul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:abhinavm
ID: 1090448
I think your connection to database is lost due to some reason because i have tried the same code and its working fine.
0
 
LVL 1

Accepted Solution

by:
kdimmock earned 800 total points
ID: 1090449
Try this ...

set nocount on
INSERT INTO table (field1, field2) VALUES (2,2)
   SELECT @@identity as ident
set nocount off
0
 

Author Comment

by:rickpaul
ID: 1090450
Perfect! I wonder if you can tell me where I might have found that in the documentation?
0
 
LVL 1

Expert Comment

by:kdimmock
ID: 1090451
It was one of those things I found by trial and error. I needed to do the same as you and was getting the same problems as you.
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question