SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Article: Returning @@IDENTITY back to an ASP Page
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 08/17/2000 :  19:30:46  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Gareth writes "Hi, I'd be so relieved if you could sort this out . . . I'm trying to get the value of @@IDENTITY from SQL Server into an ASP variable (via a recordset) - however I get an ASP error reporting that the value in the recordset (selected as 'ident') can't be found. What's going on . . . Thanks!"

Article Link.

Anonymous
Starting Member

0 Posts

Posted - 09/07/2000 :  16:33:11  Show Profile  Reply with Quote
Try this solutions

You try this way.Because @@Identity assign in temporary variable then fetch value of last inserted.
'SELECT FirstName + ' ' + LastName AS "Employee Name", IDENTITYCOL AS "Employee ID" FROM Northwind.dbo.Employees'.

or try this

'If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL'

SELECT @@IDENTITY AS 'Identity'
Now u may get value of identity.This is my gess only.

If you get any ideas from the above i will really Appreciate you.
If you don't get any help from above i am really sorry.
Pls let me know.
my id is Ramesh.Nekkanti@indsys.ge.com
Regards
Ramesh

Go to Top of Page

Anonymous
Starting Member

0 Posts

Posted - 01/26/2001 :  16:38:25  Show Profile  Reply with Quote
Other solution to NoCount

Instead of setting nocount off to avoid that error, you could do this

Set objRs = objRs.NextRecordSet

Go to Top of Page

lrthomas
Starting Member

USA
1 Posts

Posted - 05/28/2008 :  12:28:19  Show Profile  Reply with Quote
I dont use ASP I use vb 2005. How would I get the answer to the @@identity in my vb2005 code?

Lonnie R Thomas
Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11751 Posts

Posted - 05/28/2008 :  12:48:25  Show Profile  Visit spirit1's Homepage  Reply with Quote
with dataset and dataadapter or executescalar method of sqlcommand object.
if you're going to use executescalar then you have to return with "select @@identity" in your sproc.

also use scope_identity() instead of @@identity

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000