.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

@@identity

Posted By: shahin     Posted Date: January 26, 2010    Points:2   Category :ASP.Net
hi !

@@identity : it returns id of last record ...
i m retriving in storedproc...
but not hv any idea how to use in .cs file using sqlhelper class

it returns null
public int Insert1(SqlTransaction tran, string s, params object[] ob)
{
try
{
Int32 Count;
Count = Convert.ToInt32(SqlHelper.ExecuteScalar(tran, s, ob));
return Count;
}
catch
{
throw;
}

}

=======================
in .cs file

Int32 Count;
Count = bussiness.Insert1(tran, "sp_Contact_Detail_Insert", obj);
Session["id"] = Count;
tran.Commit();
ClearData();

but getting 0 in count

==========================

see in databse id filed ===identity true +1

Responses
Author: Amit Mehra             
Posted Date: January 26, 2010     Points: 5   

Hi,

To get the value returned from stored procedure you can add this line of SQL Statement at the end of rest of your sql query

select @@identity 

or you can say

select Scope_Identity()


to get the last inserted record identity value

Thanks
Amit

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: shahin             
Posted Date: January 29, 2010     Points: 5   

ya i know that
but how to use in .aspx page
i follw above code but got 0 in count

Author: shahin             
Posted Date: January 29, 2010     Points: 5   

i got value from proc properly but not in .aspx



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend