By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,412 Members | 1,630 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,412 IT Pros & Developers. It's quick & easy.

scope_identity not working

P: 115
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);
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
Jul 8 '09 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 2,878
Here, read this...

Good luck!

--- CK
Jul 8 '09 #2

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

_Pankaj Tambe
Jul 16 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.