0

Hello experts,

I have a web application in ASP.Net (C#) and SQL Server 2005. In the application the end user can enter the customer record. When one end user use the application and enter customer record it works fine. But whenever more then one end user try to enter record at same time then it shows an error. The error message shows the violation of primary key constrain.

NB: The two end user log in to the application with different user id and their records are also different. But they can't enter data at the same time.


Please help me out.

5
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by __avd
0

>The error message shows the violation of primary key constrain.

Write a store-procedure which inserts if concern primary key is not found in a database. Please show us your code.

0

In your table make Primary Key columns as Identity columns as much as possible !!!

Mark as solved if it helps you!!!

0

hi these are the possible solutions for this
- create the primary key column as autogenerate/Identity Column
- use proper locking mechanish while inserting new records in table
- create before insert trigger to generate the primary key

Edited by Ezzaral: Snipped url. Please restrict personal links to your user signature.

-1

hi these are the possible solutions for this
- create the primary key column as autogenerate/Identity Column
- use proper locking mechanish while inserting new records in table
- create before insert trigger to generate the primary key

Hi webnhosting,

Thanks for your suggestion. Well the primary key column is auto generated i.e. customer_id.
I think the lock mechanism will work while inserting the record. Can you give me a bit detail about the locking.

Regards,
Umesh Sinha

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.