Bug #58374 TableAdapterManager.UpdateAll() Error
Submitted: 22 Nov 2010 9:26 Modified: 10 Dec 2010 7:23
Reporter: wang gang Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.3.5 OS:Windows (windows7&server 2008)
Assigned to: CPU Architecture:Any
Tags: "Transaction has already been rolled back or is not pending", TableAdapterManager.UpdateAll()

[22 Nov 2010 9:26] wang gang
Description:
Enviroment:visual studio 2008 ,MySql(5.1.53-win32)
I have two Tables in my MySql server.One is the Master Table,one is the Detail Table.There have a Foreign Key created in the Detail Table.
Then I put them into the DataSet of Visual Studio 2008.
In my code,when I delete a row of the Detail Table,and execute the TableAdapterManager.UpdateAll(dataset),but an error is catched:"Transaction has already been rolled back or is not pending".
When I tracked the code row by row ,I found the deleting-row'rowstate was Deleted.but when before UpdateAll() executed row.AcceptChanges(),that row'rowstate has been changed to Dtached(importantly,it was not changed in Microsoft sql server 2005).
so, that row executes AcceptChanges()at that moment,visual studio threw an exception about "Transaction has already been rolled back or is not pending".

I think this error have more to do with the mysql connector(for .net).
Hope for your help!

How to repeat:
Deleting any row of the Detail Table by bindingsource.removecurrent(),then execute the TableAdapterManager.UpdateAll(),the error must be catched.
(The bindingsource'DataSource is the Master Table's bindingsource,and The bindingsource'DataMember is the foreign key' name.)

Suggested fix:
all version of the mysql-connector-net have the error.
[22 Nov 2010 9:40] Tonci Grgin
Hi Wang and thanks for your report.

It would be best if you can attach a small but complete test case project along with DDL/DML for tables in question.
[23 Nov 2010 3:45] wang gang
DDL
CREATE TABLE `tmaster` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mc` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `tdetail` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mc` varchar(20) DEFAULT NULL,
  `tmaster_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_tmaster_id` (`tmaster_id`),
  CONSTRAINT `fk_tmaster_id` FOREIGN KEY (`tmaster_id`) REFERENCES `tmaster` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
[23 Nov 2010 3:46] wang gang
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace testMDofMySql
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.tdetailTableAdapter.Fill(this.testaDataSet.tdetail);
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            testaDataSet.tdetailRow r = (testaDataSet.tdetailRow)((DataRowView)tdetailBindingSource.Current).Row;
            int id = r.id;

            if (dataGridView1.Columns[e.ColumnIndex].Name == "delete")
            {
                tdetailBindingSource.RemoveCurrent();
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.tableAdapterManager1.UpdateAll(testaDataSet);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
[26 Nov 2010 7:31] Tonci Grgin
I am sorry Wang but these are bits and pieces of actual project you run... Can you please attach an entire solution that I can load into VS2008 and try.

Include please relevant part of my.ini concerning InnoDB and SQL_MODE server is in.
[29 Nov 2010 4:06] wang gang
OK.
I downloaded the source file of the connector-net 6.3.5.Opened it's .sln file in visual studio 2010.
I removed the lines between 188 to 195 in dataadapter.cs.
Rebuild.
Replace the old MySql.Data.dll with this rebuilded Mysql.Data.dll in my projects.

Then,the errors disapeared.
[10 Dec 2010 7:21] Valeriy Kravchuk
Bug #58853 was marked as a duplicate of this one.
[10 Dec 2010 7:23] Tonci Grgin
Wang, your colleague in Bug#58853 described the problem better so I'll close this report and work on his.