Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Rollback a mySQL Transaction

Avatar of JedNebula
JedNebulaFlag for United Kingdom of Great Britain and Northern Ireland asked on
MySQL Server.NET Programming
4 Comments1 Solution642 ViewsLast Modified:
I am reasonably new to mySQL. Normally I use MS SQL.

I understand from doing a bit of research that the mySQL connector works slightly differently to sqlClient when it comes to rolling back transactions.

I saw this post here: http://stackoverflow.com/questions/1630400/duplicate-key-error-does-not-cancel-rollback-mysql-transaction although I didn't really understand what I read.

The scenario I am testing is that I have two Test tables (myTestTable1 and myTestTable2). Both just have an auto increment primary key and a varchar field. I have however added a unique constraint to table 2's varchar field only. I am trying to insert the same text values into both tables. Table one should succeed, but because of the constraint, table 2 should fail. I am using a transaction, so I'm assuming the Rollback of the transaction should cancel the insert of Table 1 also, but it doesn't - it remains there.

This works fine in MS SQL.

I'm a bit out of my depth here, so if someone could translate the gist of the URL above or give me a reason why the transaction is not being treated as such (or steps to make it so), I would be grateful.


Avatar of hernst42
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers