There are a few similar questions on SO and elsewhere but mostly with php and I do not understand that. I’m trying to restore a database with a 62 tables like this:
string query = @"SET SQL_MODE= 'NO_AUTO_VALUE_ON_ZERO'; CREATE DATABASE " + dbName + " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; USE " + dbName + ";" + Environment.NewLine;
using (StreamReader reader = File.OpenText("C:\b.sql"))
{
string line = reader.ReadToEnd();
query += line; //almost 1700 lines.
}
// upto this i get the query correctly which works fine in phpMyAdmin.
MySqlCommand c = new MySqlCommand(query, conn);
c.ExecuteReader();
//but when I execute, throws: "Fatal error encountered during command execution."
Why is this so? If it’s ‘cos of the length of the query, then how can I execute such large queries from the application?
try this for check error:
Edit
for better performance, you can use this class. I have not tried it, hope it works well: