Bug #4658 MySqlCommandBuilder
Submitted: 20 Jul 2004 23:19 Modified: 5 Aug 2004 22:36
Reporter: jorge beckhauser
Status: Closed
Category:Connector/Net Severity:S3 (Non-critical)
Version:0.76.15073 OS:Microsoft Windows (Windows)
Assigned to: Reggie Burnett Target Version:

[20 Jul 2004 23:19] jorge beckhauser
Description:
Bug with DataAdapter Property of MySqlCommandBuilder class.

Using:
----------------------- 
MySqlCommandBuilder cb=new MySqlCommandBuilder();
cb.DataAdapter=myDataAdapter1;
...
myDataAdapter.Update(dataSet1, "TableName");
-----------------------
gives an error :
A atualização requer um UpdateCommand válido para transmitir coleção DataRow com
linhas modificadas.
"The Updating requery a valid UpdateCommand to transmit DataRow collection with modified
lines."

How to repeat:
using System;
using System.Windows.Forms;
using System.Data;
using ByteFX.Data.MySqlClient;
using MySQLDriverCS;

namespace DefaultNamespace
{
	public class MainForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.Button button2;
		private MySqlDataAdapter da;
		private DataSet ds;
		private MySqlConnection conn;
		public MainForm()
		{
			InitializeComponent();
		}
		
		[STAThread]
		public static void Main(string[] args)
		{
			Application.Run(new MainForm());
		}
		
		#region Windows Forms Designer generated code
		private void InitializeComponent() {
			this.button2 = new System.Windows.Forms.Button();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.button1 = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// button2
			// 
			this.button2.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom |
System.Windows.Forms.AnchorStyles.Right)));
			this.button2.Location = new System.Drawing.Point(128, 232);
			this.button2.Name = "button2";
			this.button2.TabIndex = 2;
			this.button2.Text = "Update";
			this.button2.Click += new System.EventHandler(this.Button2Click);
			// 
			// dataGrid1
			// 
			this.dataGrid1.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Bottom) 
						| System.Windows.Forms.AnchorStyles.Left) 
						| System.Windows.Forms.AnchorStyles.Right)));
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(8, 8);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(280, 208);
			this.dataGrid1.TabIndex = 0;
			// 
			// button1
			// 
			this.button1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom |
System.Windows.Forms.AnchorStyles.Right)));
			this.button1.Location = new System.Drawing.Point(216, 232);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(72, 24);
			this.button1.TabIndex = 1;
			this.button1.Text = "Retrieve";
			this.button1.Click += new System.EventHandler(this.Button1Click);
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 266);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.dataGrid1);
			this.Name = "MainForm";
			this.Text = "MainForm";
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);
		}
		#endregion
		void Button1Click(object sender, System.EventArgs e)
		{
			conn=new MySqlConnection("Database=cahti;Data Source=netserver;User
Id=root;Password=xxx");
			conn.Open();
			
			da=new MySqlDataAdapter("SELECT * FROM cob_clientesaparthotel",conn);
			MySqlCommandBuilder cb=new MySqlCommandBuilder();
-----------------------------------------------------------------------------
			cb.DataAdapter=da; //does not work properly
-----------------------------------------------------------------------------
			
			ds=new DataSet();
			da.Fill(ds,"Clientes");
			
			dataGrid1.SetDataBinding(ds,"Clientes");
		}
		
		void Button2Click(object sender, System.EventArgs e)
		{
			da.Update(ds, "Clientes");
		}
	}
}

Suggested fix:
Using:
----------------------- 
MySqlCommandBuilder cb=new MySqlCommandBuilder(myDataAdapter1);
//cb.DataAdapter=myDataAdapter1;
...
myDataAdapter.Update(dataSet1, "TableName");
-----------------------

solve the problem.
[27 Jul 2004 5:25] Matthew Lord
I was able to repeat the given error using the source file provided.
[5 Aug 2004 22:36] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

I was able to verify this also using 0.76 and this has been fixed in our source
repository.