Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

MySQLDataAdapter seems to have a problem with updating rows with fully defined Double values!? (no replies)

$
0
0
Dear MySQL .Net forum,

I've come across something that seems strange to me.

Every time I save double-values that are not fully defined, e.g. only have 10 significant digits, everything is well. I'm able to update the row with the MySQLDataAdaptor. I'm also able to update the double with at fully defined double value (~15 significant digits).

But as soon the row store a fully defined double, I'm unable to update this row using the MySQLDataAdaptor !? The whole row is blocked from updates. When I issue the DataAdaptor.Update(DataTable) command, I get the: DBConcurrencyException defining the row that contains the fully defined double.

I've put together the following example that triggers my problem:

###############################################################################
MySqlConnectionStringBuilder connBuilder = new MySqlConnectionStringBuilder();
connBuilder.Add("Database", "test");
connBuilder.Add("Data Source", "localhost");
connBuilder.Add("User Id", "root");
connBuilder.Add("Password", "rootpw");
MySqlConnection connection = new MySqlConnection(connBuilder.ConnectionString);
MySqlCommand cmd = connection.CreateCommand();

connection.Open();

cmd.CommandText = "DROP TABLE IF EXISTS testtable3;";
cmd.ExecuteNonQuery();
cmd.CommandText = "CREATE TABLE `test`.`testtable3` (`id` int(10) unsigned NOT NULL,`d` double NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
cmd.ExecuteNonQuery();
cmd.CommandText = "INSERT INTO testtable3 (id, d) VALUES(1, 0.123456789123456789);";
cmd.ExecuteNonQuery();

DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM testtable3;", connection);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);

da.Fill(dt);
dt.PrimaryKey = new DataColumn[] { dt.Columns["id"] };

DataRow dr = dt.Rows.Find(1);
if (dr == null)
{
dr = dt.NewRow();
dr["d"] = 0.12;
dt.Rows.Add(dr);
}
else
dr["d"] = 0.12;

da.Update(dt); // <- EXCEPTION IS THROWN HERE

connection.Close();
###############################################################################

Am I missing something here? It seems very strange!

Regards
Jonas

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>