Connecting Tech Pros Worldwide Forums | Help | Site Map

scope_identity not working

Member
 
Join Date: Apr 2007
Location: india
Posts: 111
#1: Jul 8 '09
hi am developing c# project am create dataset and dataadapter my code here
Expand|Select|Wrap|Line Numbers
  1. shoppingDataSet1TableAdapters.productdetailsTableAdapter productadapter = new shoppingDataSet1TableAdapters.productdetailsTableAdapter();
  2.             int productid = productadapter.insertproduct(categoryid, productname, productdesc, prodcutrate, isnew,brandid, picname);
  3.  
  4.  
my sql statement here
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [productdetails] ([categoryid], [productname], [productdesc], [rate], [status], [isnew], [brandid], [homeimg]) VALUES (@categoryid, @productname, @productdesc, @rate, 1, @isnew, @brandid, @homeimg);
  2. select @@identity as  productid

but it is always return 1

pls help

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Jul 8 '09

re: scope_identity not working


Here, read this...

Good luck!

--- CK
Newbie
 
Join Date: Jul 2009
Posts: 9
#3: Jul 16 '09

re: scope_identity not working


Insted of "select @@identity as productid[/code]"
You can use select SCOPE_IDENTITY()

_Pankaj Tambe
Reply