473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

scope_identity not working

115 100+
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
Jul 8 '09 #1
2 3269
ck9663
2,878 Expert 2GB
Here, read this...

Good luck!

--- CK
Jul 8 '09 #2
Insted of "select @@identity as productid[/code]"
You can use select SCOPE_IDENTITY()

_Pankaj Tambe
Jul 16 '09 #3

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

Similar topics

4
by: Scrappy | last post by:
I have an ASP front end on SQL 2000 database. I have a form that submits to an insert query. The entry field is an "identity" and the primary key. I have used scope_identity() to display the...
1
by: Lauren Quantrell | last post by:
I'm using an Access2K front end on a SQL Server2K backend. I use Scope_Identity() in a lot of stored procedures to pass the newwly inserted record's unique ID to the next select statement in the...
5
by: Larry | last post by:
I am seeing a problem with an ASP application, where I have 2 tables. In the first table, the ASP inserts just 1 row and retrieves the primary key of the new row using SCOPE_IDENTITY. It then uses...
6
by: Hardy Wang | last post by:
Hi all, I have the following codes, but SCOPE_IDENTITY() just returns NULL to me. If I comment out SCOPE_IDENTITY() line and run @@IDENTITY line, it works fine!! Since I have a trigger on the...
4
by: Mr Newbie | last post by:
I was using this fine sqlIDQuery = "SELECT SectionID FROM SECTIONS WHERE (SectionID=SCOPE_IDENTITY());" UNTIL. . . . I added a parameter, now it fails, it doesent matter if I use the...
4
by: Mr Newbie | last post by:
The following code is comprises a function to create a section of a documemt. Each section is stored in a table. This successfully inserts a record in the Sections table, but the scope_identity()...
1
by: Justyn | last post by:
Hi everyone, I hope someone can help me out! I have added a trigger that gets fired on INSERT and which itself inserts data into another table WITHOUT an identity I used to get back the...
1
by: David Lozzi | last post by:
Howdy, ASP.Net 2.0 using VB on SQL 2005 This is a two fold issue. I have a DetailsView control which users can insert or edit items. Editing works great. Insert works great however I need...
10
by: Mike | last post by:
Sql Server, Scope_Identity(), Ado.NET: Which is better? Using an output parameter to return Scope_Identity through ExecuteNonQuery(), or adding Select Scope_Identity() to the end of the...
3
by: Miro | last post by:
I am trying to get my ID added from a people table in an access table "MyContacts.mdb" i just added. Its basically a contact file i created in access: PK Person_ID - Unique - autoincrement...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.