Solved

Need @@identity in an ASP

Posted on 1998-10-07
4
205 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 200 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

635 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