Provides data for the InfoMessage event. This class cannot be inherited.
Inheritance: System.EventArgs
Exemple #1
0
        public virtual List <MySqlError> ReportWarnings(MySqlConnection connection)
        {
            List <MySqlError> warnings = new List <MySqlError>();

            MySqlCommand cmd = new MySqlCommand("SHOW WARNINGS", connection);

            cmd.InternallyCreated = true;
            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    warnings.Add(new MySqlError(reader.GetString(0),
                                                reader.GetInt32(1), reader.GetString(2)));
                }
            }

            MySqlInfoMessageEventArgs args = new MySqlInfoMessageEventArgs();

            args.errors = warnings.ToArray();
            if (connection != null)
            {
                connection.OnInfoMessage(args);
            }
            return(warnings);
        }
Exemple #2
0
        public void ReportWarnings()
        {
            ArrayList errors = new ArrayList();

            MySqlCommand cmd = new MySqlCommand("SHOW WARNINGS", connection);

            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    errors.Add(new MySqlError(reader.GetString(0),
                                              reader.GetInt32(1), reader.GetString(2)));
                }

                hasWarnings = false;
                // MySQL resets warnings before each statement, so a batch could indicate
                // warnings when there aren't any
                if (errors.Count == 0)
                {
                    return;
                }

                MySqlInfoMessageEventArgs args = new MySqlInfoMessageEventArgs();
                args.errors = (MySqlError[])errors.ToArray(typeof(MySqlError));
                if (connection != null)
                {
                    connection.OnInfoMessage(args);
                }
            }
        }
 internal void OnInfoMessage(MySqlInfoMessageEventArgs args)
 {
     if (this.InfoMessage != null)
     {
         this.InfoMessage(this, args);
     }
 }
 /// <summary>
 /// Handles the InfoMessage event of the conn control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="args">The <see cref="T:MySql.Data.MySqlClient.MySqlInfoMessageEventArgs"/> instance containing the event data.</param>
 private void conn_InfoMessage (object sender, MySqlInfoMessageEventArgs args) {
     //Gets last MySQL error and format it
     MySqlError lastError = args.errors[args.errors.Length - 1];
     string error = String.Format(
         "Error #{0} - {2} [{1}]",
         lastError.Code,
         lastError.Level,
         lastError.Message
     );
     
     //Throws an exception to our Error event
     if (Error != null) Error(this, new ExceptionEventArgs(new Exception(error)));
     
 }
Exemple #5
0
        public virtual List <MySqlError> ReportWarnings(MySqlConnection connection)
        {
            List <MySqlError> list = new List <MySqlError>();

            using (MySqlDataReader mySqlDataReader = new MySqlCommand("SHOW WARNINGS", connection)
            {
                InternallyCreated = true
            }.ExecuteReader())
            {
                while (mySqlDataReader.Read())
                {
                    list.Add(new MySqlError(mySqlDataReader.GetString(0), mySqlDataReader.GetInt32(1), mySqlDataReader.GetString(2)));
                }
            }
            MySqlInfoMessageEventArgs mySqlInfoMessageEventArgs = new MySqlInfoMessageEventArgs();

            mySqlInfoMessageEventArgs.errors = list.ToArray();
            if (connection != null)
            {
                connection.OnInfoMessage(mySqlInfoMessageEventArgs);
            }
            return(list);
        }
Exemple #6
0
        public void ReportWarnings()
        {
            ArrayList       arrayList       = new ArrayList();
            MySqlCommand    mySqlCommand    = new MySqlCommand("SHOW WARNINGS", this.connection);
            MySqlDataReader mySqlDataReader = null;

            try
            {
                mySqlDataReader = mySqlCommand.ExecuteReader();
                while (mySqlDataReader.Read())
                {
                    arrayList.Add(new MySqlError(mySqlDataReader.GetString(0), mySqlDataReader.GetInt32(1), mySqlDataReader.GetString(2)));
                }
                mySqlDataReader.Close();
                this.hasWarnings = false;
                if (arrayList.Count != 0)
                {
                    MySqlInfoMessageEventArgs mySqlInfoMessageEventArgs = new MySqlInfoMessageEventArgs();
                    mySqlInfoMessageEventArgs.errors = (MySqlError[])arrayList.ToArray(typeof(MySqlError));
                    if (this.connection != null)
                    {
                        this.connection.OnInfoMessage(mySqlInfoMessageEventArgs);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (mySqlDataReader != null)
                {
                    mySqlDataReader.Close();
                }
            }
        }
Exemple #7
0
 internal void OnInfoMessage(MySqlInfoMessageEventArgs args)
 {
     if (InfoMessage != null)
     {
         InfoMessage(this, args);
     }
 }
Exemple #8
0
 internal void OnInfoMessage(MySqlInfoMessageEventArgs args)
 {
     InfoMessage?.Invoke(this, args);
 }
Exemple #9
0
        public virtual List<MySqlError> ReportWarnings(MySqlConnection connection)
        {
            List<MySqlError> warnings = new List<MySqlError>();

            MySqlCommand cmd = new MySqlCommand("SHOW WARNINGS", connection);
            cmd.InternallyCreated = true;
            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    warnings.Add(new MySqlError(reader.GetString(0),
                                              reader.GetInt32(1), reader.GetString(2)));
                }
            }

            MySqlInfoMessageEventArgs args = new MySqlInfoMessageEventArgs();
            args.errors = warnings.ToArray();
            if (connection != null)
                connection.OnInfoMessage(args);
            return warnings;
        }
Exemple #10
0
        public void ReportWarnings()
        {
            ArrayList errors = new ArrayList();

            MySqlCommand cmd = new MySqlCommand("SHOW WARNINGS", connection);
            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    errors.Add(new MySqlError(reader.GetString(0),
                                              reader.GetInt32(1), reader.GetString(2)));
                }

                hasWarnings = false;
                // MySQL resets warnings before each statement, so a batch could indicate
                // warnings when there aren't any
                if (errors.Count == 0) return;

                MySqlInfoMessageEventArgs args = new MySqlInfoMessageEventArgs();
                args.errors = (MySqlError[]) errors.ToArray(typeof (MySqlError));
                if (connection != null)
                    connection.OnInfoMessage(args);
            }
        }
 private void conn_info_message(object sender, MySqlInfoMessageEventArgs e)
 {
     Debug.WriteLine("[Info Message]");
     Debug.WriteLine("InfoMesage : {0}", e.errors);
     Debug.WriteLine("");
 }