| Bug #43327 | Transaction/Rollback | ||
|---|---|---|---|
| Submitted: | 3 Mar 2009 11:40 | Modified: | 9 Mar 2009 9:15 |
| Reporter: | R Roberts | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / NET | Severity: | S2 (Serious) |
| Version: | 5.2.1 | OS: | Windows |
| Assigned to: | CPU Architecture: | Any | |
[3 Mar 2009 11:41]
R Roberts
I have tried this approach and yet again it still did not rollback either; just kept
inserting it:
int RowsAffected = 0;
manufacturersTableAdapter X = new manufacturersTableAdapter();
X.Connection.Open();
MySqlTransaction myTrans = X.Connection.BeginTransaction();
X.AttachTransaction(myTrans);
try
{
DataSet1.manufacturersDataTable manuRows = X.GetAllManufacturers();
DataView view = new DataView(manuRows);
view.RowFilter = "manufacturer_id = '" + Code + "'";
if (view.Count == 0)
{
X.Insert(Code, Description);
throw new Exception();
}
else
{
texstatus = "The code you have entered is already in use. Please use another.";
}
}
catch (Exception ex)
{
myTrans.Rollback();
texstatus = "Transaction has been aborted!";
}
[3 Mar 2009 11:41]
R Roberts
Any luck with it? Is there a way to resolve this please?
[3 Mar 2009 11:50]
Tonci Grgin
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug. Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/ Thank you for your interest in MySQL. Explanation: Hi Romy and thanks for your report. I should not do neither code-review nor manual reading for reporters... Anyways, you are probably using transactional storage engine and have auto_commit set to true. Please see documentation regarding this.
[9 Mar 2009 9:15]
R Roberts
Hi I realised that I cannot ask questions or advice regarding this. But I have spent over 4 months trying to get the transactions to work in C#. I have checked the MySql database which uses INNODB and also I have turned off the AUTOCOMMIT. But I still cannot get the transactions to work directly in C# (VS2005). I have really tried hard to post all the problems with transactions on the forum and yet I have had little feedback. I cannot get my project moving forward because of the transaction 'stalemate' problem. Can you please please help out on what I am missing or is there something wrong with my C# coding? Sincerely appreciate the time and effort you are putting into this. Thanks Romy

Description: Hi I seem to be having problems in trying to do a rollback on C# VS 2005. I am using MySQLConnector.Net 5.2.1, SQLYog CommunityEdition v6.16, VS 2005 (C#). I have created datatable through XSD Wizard (dataset.xsd). Then on my BLL (Business layer logic) - I have coded with transactionscope etc but it refuses to do a rollback. I can't be sure if this is a bug and if it is not a bug; can you please tell me how it should be done. I have read on the internet - that it is a bug. Thanks Romy How to repeat: Just a table with two columns Using XSD Then did the coding in BLL public bool DeleteManufacturersBrandByManuID(string ManuID, out string strErrMsg, out StringBuilder sbSQLText) { sbSQLText = new StringBuilder(); strErrMsg = string.Empty; int RowsAffected = 0; DatabaseConn db = new DatabaseConn(); try { MySqlTransaction trans = db.conn.BeginTransaction(); using (TransactionScope txScope = new TransactionScope()) { RowsAffected = ManuBrandAdapter.DeleteManufacturers_BrandByManuID(ManuID); trans.Rollback(); txScope.Complete(); } } catch (TransactionAbortedException tex) { texstatus = tex.Message.ToString(); } if ((taestatus.Length > 0) || (texstatus.Length > 0)) { errMsg = new ErrorMessage(); strErrMsg = errMsg.GeneralErrorMessage(taestatus, texstatus, "DeleteManufacturersBrandByManuID"); sbSQLText.Append("DELETE FROM manufacturers_brands WHERE (manufacturer_id =" + ManuID + ")/r/n"); } db.conn.Close(); return (RowsAffected == 1); }