0

I'm learning to use MySqlScript Class, and I think that I already know how to execute MySQL Scritps from file and also know what statement has just executed (with StatementExecuted event).. but what about MySQL warnings? is there a way to display results or the warnings of each statement in a script?

I would like to show the SQL statement with the corresponding warnings / rows affected

MySqlScript script = new MySqlScript(myConexion, File.ReadAllText(openFileDialog1.FileName));
script.StatementExecuted += Script_StatementExecuted;
script.Execute();


private void Script_StatementExecuted(object sender, MySqlScriptEventArgs args)
{
    MessageBox.Show(args.StatementText); // this is only a test, this will be stored in some other place not displayed as a message;
}
Steve
  • 213,761
  • 22
  • 232
  • 286
Jorge
  • 17
  • 4
  • Possible duplicate of [mysql load data local show warning from C#](https://stackoverflow.com/questions/41941613/mysql-load-data-local-show-warning-from-c-sharp) – nilsK Aug 10 '18 at 14:07
  • `MySqlInfoMessageEventArgs.errors` is an array of `MySqlError` that has a property `Level` - see [MSDN docs here](https://dev.mysql.com/doc/dev/connector-net/6.10/html/T_MySql_Data_MySqlClient_MySqlError.htm) – nilsK Aug 10 '18 at 14:10
  • Thank you, as I understood the MySqlInfoMessageEventArgs from InforMessage Event will help me to get the warnings with Level property. So I write the following code but: 1) I don’t know why it throws the same message like 15 times and 2) I would like to get the number of rows affected is that possible? {.. myConn.InfoMessage += MyConn_InfoMessage; private void MyConn_InfoMessage(object sender, MySqlInfoMessageEventArgs args) { MessageBox.Show(args.errors[0].Level + " : " + args.errors[0].Message + " count: " + args.errors.Count()); } ..} – Jorge Aug 10 '18 at 16:46

0 Answers0