The string of input characters was not in an incorrect format.

Jan 31, 2015 at 2:06 PM
Edited Jan 31, 2015 at 2:07 PM
I got this exception while executing this code:
var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Entities"].ConnectionString;

                string constring = connectionString.Substring(connectionString.IndexOf("server=")).ToString().Replace("\"", "");

                string file = "backup_" + DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss") + ".sql";
                using (MySqlConnection conn = new MySqlConnection(constring))
                {
                    using (MySqlCommand cmd = new MySqlCommand())
                    {
                        using (MySqlBackup mb = new MySqlBackup(cmd))
                        {
                            cmd.Connection = conn;
                            conn.Open();
                            mb.ExportToFile(path + "\\" + file);
                            conn.Close();
                        }
                    }
                }
Exception:
The string of input characters was not in an incorrect format.
the file name is correct, the folder is correct, the error trhow at line mb.ExportToFile(...
Coordinator
Jan 31, 2015 at 11:53 PM
Edited Jan 31, 2015 at 11:56 PM
First, you can try to do it with a simple fixed filename and fixed folder path.
Test it. If you can success with this, then expand the code to generate filename at runtime according to time.

Simple test:
string file = "backup.sql";
string path = "D:\\mysqlbackup";
            
if (!System.IO.Directory.Exists(path))
{
    System.IO.Directory.CreateDirectory(path);
}
            
string filepath = System.IO.Path.Combine(path, file);

....

mb.ExportToFile(filepath);

Feb 2, 2015 at 9:01 PM
I tryed to do it, but i got the same error.
The file was created, but its empty.
Coordinator
Feb 2, 2015 at 11:40 PM
Well, I'm unable to guess what was happening to you.
Upload a sample project at ISSUES that will produce the error, then I'll have a look at it.
Feb 3, 2015 at 10:39 AM
I tryied in a blank projet, and got the same error.
i dont know what else i can do.
Do you know any other solution than MySqlBackup.Net that makes easy mysql backup too ?
Feb 4, 2015 at 3:38 PM
I've same problem with backup of Joomla db
The problem is "timestamp" column type and class MySqlColumn

A workaround is to change in costructor of class MySqlColumn:
_timeFractionLength = Convert.ToInt32(_fractionLength);
with:
int fractionTimeValue = 0;
int.TryParse(_fractionLength, out fractionTimeValue);
_timeFractionLength = fractionTimeValue;
Another problem is the export of the rows with the data type timestamp. In this case add to the connection string:
Convert Zero Datetime=True
Coordinator
Feb 4, 2015 at 11:20 PM
hello sfvaleriano,

Thanks for the info :)
Coordinator
Feb 24, 2015 at 10:19 PM
I have fix this. Try V2.0.8.