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.

Recommended Answers

All 6 Replies

>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.

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

Mark as solved if it helps you!!!

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 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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.