• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Need @@identity in an ASP

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
rickpaul
Asked:
rickpaul
  • 2
1 Solution
 
abhinavmCommented:
I think your connection to database is lost due to some reason because i have tried the same code and its working fine.
0
 
kdimmockCommented:
Try this ...

set nocount on
INSERT INTO table (field1, field2) VALUES (2,2)
   SELECT @@identity as ident
set nocount off
0
 
rickpaulAuthor Commented:
Perfect! I wonder if you can tell me where I might have found that in the documentation?
0
 
kdimmockCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now