I redid everything, but I do not receive data on the line (constantly 0). Full code:
private void doScripts(string[] scripts, string server, string @base, string login, string paswd) { if (scripts == new string[] { }) { MessageBox.Show("ΠΡΠ±Π΅ΡΠ΅ΡΠ΅ ΡΠΊΡΠΈΠΏΡ Π΄Π»Ρ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ!"); return; } Connect = "default command timeout=0 ; Database=" + @base + "; Data Source=" + server + "; User Id=" + login + "; Password=" + paswd + "; charset=utf8"; MySqlConnection myConnection = new MySqlConnection(Connect); if (this.OpenConnection(myConnection) == true) // ΠΡΠΎΠ²Π΅ΡΠΊΠ° ΠΊΠΎΠ½Π½Π΅ΠΊΡΠ° { foreach (var item in scripts) { // ΠΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΡΠΊΡΠΈΠΏΡ ------------------------------------------------------------------------------------------------- MySqlScript script = new MySqlScript(myConnection, EncodingUTF8orANSI(item)); bool errorHappened = false; bool errorIgnore = false; int errorPosition = 0; //string errorStatement = ""; string errorStatementText = ""; int errorLine = -1; int count = 0; MySqlScriptErrorEventHandler handler = (sender1, args) => { errorHappened = true; errorLine = args.Line; errorIgnore = args.Ignore; errorPosition = args.Position; //errorStatement = args.Statement; errorStatementText = args.StatementText; richTextBox1.AppendText("\n errorPosition: " + errorPosition + // 0 "\n errorStatementText: " + errorStatementText + // "" "\n Line: " + errorLine + // 0 "\n count: " + count + // 0 "\n ERROR: " + args.Exception.Message + // Π²ΡΠ΄Π°Π΅Ρ ΠΎΡΠΈΠ±ΠΊΡ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ, ΠΊΠ°ΠΊ ΠΈ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΎ "\n args.Position: " + args.Position); // Π²ΡΠ΄Π°Π΅Ρ ΠΎΡΠΈΠ±ΠΊΡ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ, ΠΊΠ°ΠΊ ΠΈ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΎ DoScriptsResult = "ERROR"; }; try { script.Error += handler; //script.Error += new MySqlScriptErrorEventHandler(script_Error); script.ScriptCompleted += new EventHandler(script_ScriptCompleted); script.StatementExecuted += new MySqlStatementExecutedEventHandler(script_StatementExecuted); count = script.Execute(); } catch (MySqlException ex) { DoScriptsResult = "ERROR"; } finally { richTextBox1.AppendText("\n finally"); } if (errorHappened) { richTextBox1.AppendText("\n ERROR"); } private void script_Error(Object sender, MySqlScriptErrorEventArgs args) { richTextBox1.AppendText("\n args.Ignore: " + args.Ignore + // 0 "\n args.Position: " + args.Position + // "" "\n args.StatementText: " + args.StatementText + // 0 "\n args.Line: " + args.Line + // 0 "\n ERROR: " + args.Exception.Message); // Π²ΡΠ΄Π°Π΅Ρ ΠΎΡΠΈΠ±ΠΊΡ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ, ΠΊΠ°ΠΊ ΠΈ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΎ } private void script_StatementExecuted(object sender, MySqlScriptEventArgs args) { richTextBox1.AppendText("\n script_StatementExecuted"); } private void script_ScriptCompleted(object sender, EventArgs e) { richTextBox1.AppendText("\n script_ScriptCompleted"); /// EventArgs e will be EventArgs.Empty for this method }
In response, I get:
script_StatementExecuted script_StatementExecuted args.Ignore: False args.Position: 0 args.StatementText: args.Line: 0 ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`,`assistant_id`) select `id`,`createDatetime`,`createPerson_id`, `modifyDatetim' at line 4 script_ScriptCompleted finally
Here is the script:
set foreign_key_checks=0; set sql_safe_updates = 0; insert into Visit (`id`,`createDatetime`,`createPerson_id`, `modifyDatetime`,`modifyPerson_id`,`deleted`,`event_id`,`scene_id`, `date`,`visitType_id`,`person_id`,`isPrimary`,`finance_id`,`service_id`, payStatus`,`assistant_id`) select `id`,`createDatetime`,`createPerson_id`, `modifyDatetime`,`modifyPerson_id`,`deleted`,`event_id`,`scene_id`,`date`, `visitType_id`,`person_id`,`isPrimary`,`finance_id`,`service_id`,`payStatus`, `assistant_id` from base2.Visit; set foreign_key_checks=1;
It is necessary to get the 5th line, there is an error in the request. (quotes are not in the 8th line)