Bug #5023 Concurrency error with float columns
Submitted: 12 Aug 2004 20:56 Modified: 13 Aug 2004 0:20
Reporter: Matthew Aznoe Email Updates:
Status: Duplicate Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:ByteFX OS:Microsoft Windows (Windows XP)
Assigned to: Assigned Account CPU Architecture:Any

[12 Aug 2004 20:56] Matthew Aznoe
When a row in a DataTable is modified that contains a column of type Float, a concurrency exception is always thrown whether the float value has been changed or not.  The repeat section contains the code to reproduce the error including the SQL to generate the table in question.

How to repeat:
using ByteFX.Data.MySqlClient;
using System;
using System.Data;

namespace DBTester
	class Class1
		static void Main(string[] args)
			MySqlConnection		clConnection		= new MySqlConnection( "Data Source=localhost;User ID=root;Database=dbtest" );
			MySqlCommand			clCommand			= new MySqlCommand();
			MySqlDataAdapter		clAdapter			= new MySqlDataAdapter();
			MySqlCommandBuilder	clCommandBuilder	= new MySqlCommandBuilder( clAdapter );
			string					sCommand				= "SELECT * FROM testtable";
			DataTable				dtDataTable			= new DataTable();

				clCommand.Connection = clConnection;

				// Get data from the database.
				clCommand.CommandText = sCommand;
				clAdapter.SelectCommand = clCommand;

				// Change the database record
				dtDataTable.Rows[0]["name"] = "John";

				// Reset commands and adapter for new update.
				clConnection				= new MySqlConnection( "Data Source=localhost;User ID=root;Database=dbtest" );
				clCommand					= new MySqlCommand();
				clAdapter					= new MySqlDataAdapter();
				clCommandBuilder			= new MySqlCommandBuilder( clAdapter );
				clCommand.Connection		= clConnection;
				clCommand.CommandText	= sCommand;
				clAdapter.SelectCommand = clCommand;

				clAdapter.Update( dtDataTable );

				Console.WriteLine("Data updated successfully.");
			catch( Exception ex )

create table testtable
	id			int unsigned auto_increment not null,
	name		varchar(255) not null,
	salary	float not null,
	primary key( id )
insert into testtable values( null, "Dave", 9.55 );

Suggested fix:
The DataAdapter needs to recognize when the float value has actually changed from the last read.  This could be some kind of rounding issue with floating point comparisons.
[12 Aug 2004 21:36] Matthew Aznoe
My mistake.  I found another bug reporting this issue, and it appears to be resolved (use decimal).  Are there any plans to fix this issue for float or double values, or do we have to use decimal?