Dump Example error

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Johnny Lung
Posts: 1
Joined: Fri 14 Oct 2005 11:18

Dump Example error

Post by Johnny Lung » Fri 14 Oct 2005 11:28

VS:2003 and CoreLab.MySql:

When using C# dump example come with CoreLab installer, I tried to backup an MySQL 4.0 DB in Traditional Chinese and save the file. The file give text like:

The DB table charset is utf8 and InnoDB.

What code should I modify to have correct text?

Backup function:

Code: Select all

    private void btBackup_Click(object sender, System.EventArgs e) {
      StringBuilder Tables = new StringBuilder();

      foreach (String str in lbSelected.Items)
      mySqlDump.Tables = Tables.ToString();
      statusBar.Panels[0].Text = "Backup in progress";
      statusBar.Panels[0].Text = "Backup complete";
Save function:

Code: Select all

    private void btSave_Click(object sender, System.EventArgs e) {
      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
        Stream stream = saveFileDialog.OpenFile();
        if (stream != null) {
          statusBar.Panels[0].Text = "Save in progress";
          Encoding unicodeString = Encoding.Unicode;
          stream.Write( unicodeString.GetBytes(mySqlDump.DumpText), 0, unicodeString.GetBytes(mySqlDump.DumpText).Length);
          statusBar.Panels[0].Text = "Save complete";


Post by Serious » Fri 14 Oct 2005 12:39

To use UTF-8 character set please set MySqlConnection.Unicode = true.
For additional information refer to this property documentation.

Post Reply