Exception when inserting special character

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
noah
Posts: 3
Joined: Fri 25 Jun 2010 15:21

Exception when inserting special character

Post by noah » Fri 25 Jun 2010 15:37

Take a look at this special character -> ’
It looks like an apostrophe, right? But it's not. Here's an apostrophe -> '

That special character is not on my keyboard and is pasted from Word.

I have a test DB with a test table with a single TEXT column called testtext. The following query runs without a hiccup (and the insert is performed):
insert into test (testtext) values ('hey y’all');
(notice that special character in there)

However, the following code throws an exception at SaveChanges:

Code: Select all

                var test = new test();
                test.testtext = "hey y’all";
                ent.tests.AddObject(test);
                ent.SaveChanges();
The exception thrown is:
Incorrect string value: '\x92all' for column 'testtext' at row 1
Stack trace:
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)\r\n at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)\r\n at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)\r\n at System.Data.Objects.ObjectContext.SaveChanges()\r\n ...
I emailed support and haven't even received a response.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 29 Jun 2010 10:30

I've tried to insert this special character using Entity Framework and succeeded. Could you please specify the version of MySQL server you are using and its character set?

noah
Posts: 3
Joined: Fri 25 Jun 2010 15:21

Post by noah » Mon 12 Jul 2010 15:53

Version of MySQL is 5.5 character set is UTF8. Inserts work fine from the command line/mysql workbench, but fail from EF with dotConnect pro 5.7.124

Other special characters throw exceptions as well. Last week I had an issue with this character:

»

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 13 Jul 2010 12:07

Could you please specify the following:
- the values of server variables specifying the character set; you can get them, e.g., by executing this command:

Code: Select all

show variables like '%char%';
- the exact script creating the test table (including its 'CHARACTER SET' property).

At the moment, we couldn't reproduce the issue in our environment.

Also, when executing the insert as a plain SQL command, did you use some standard tool or the MySqlCommand.ExecuteNonQuery method? Can the problem be reproduced in the latter case?

Post Reply