Share via


MySql.Data.MySqlClient.MySqlException: Duplicate entry '1' for key 'PRIMARY

Question

Saturday, April 19, 2014 12:58 PM

Hi All

Iam  new in asp.net. I have followed the tutorial in asp.net mvc 4 for creating web app. When connecting with ms sql server i can enter many  view data.(works fine)

So my new scenario, i need to send data to mysql database. the problem comes when sending the second data.the application increment primary keys as the results a get a key duplicate error.

MySql.Data.MySqlClient.MySqlException: Duplicate entry '1' for key 'PRIMARY

I know mysql database handle autoincrement by default.

any assistance will be appreciated.

All replies (1)

Monday, April 21, 2014 5:29 AM ✅Answered

Hi ifm1983,

Thank you for posting in the MSDN forum.

If it is related to the ASP.net, you could post this issue in http://forums.asp.net where asp.net experts live in.

But as you said that it is related to the MySQL, you know that actually we didn’t support the third party tool, so maybe you could post this issue to the MySQL forum for dedicated support. Thanks for your understanding.

The MySQL forum:

http://forums.mysql.com/ 

MySql.Data.MySqlClient.MySqlException: Duplicate entry '1' for key 'PRIMARY

In addition, I also did some research about the above error, maybe you could check whether it is related to the MySQL version or the connection string code.

Reference:

http://stackoverflow.com/questions/10236241/unhandled-exception-mysql-data-mysqlclient-mysqlexception-duplicate-entry-cc2

http://stackoverflow.com/questions/18397376/mysql-session-state-provider-crashes-on-expired-sessions

http://bugs.mysql.com/bug.php?id=70409

Best Regard,

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.