Question

I am currently trying to use MySqlBulkLoader in a .NET application for adding Unicode and UTF8 formatted data. My Code does the following

  • writes a tab delimited text file using a TextWriter and Stream writer

    using (TextWriter tr = new StreamWriter(newFile, false, Encoding.UTF8))

  • Opens the MySqlBulkLoader using a connection string with Charset=utf8; at the end

    MySqlBulkLoader bl = new MySqlBulkLoader(new MySqlConnection(mysqlconnstring));

  • BL has a character set to UTF8

    bl.CharacterSet = "utf8";

  • Then I call bl.Load();

but when i check the DB, i am getting ? for Unicode characters... I have checked the Text file i am writing to, and the characters are showing correctly.

I have tried setting the Collation of the Database and table to utf8_bin, based on [this question1 but i am still getting ?... What am i doing wrong?

Was it helpful?

Solution

Right... Even after setting the Collation of the tables, it made no difference, but you do need to set the charset of the table itself... I did the following...

ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

and it worked! happy days!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top