Arma2NETMySQLPlugin.MySQL.RunOnDatabase C# (CSharp) Méthode

RunOnDatabase() private méthode

private RunOnDatabase ( MySqlCommand command, int maxResultSize ) : string[][]
command MySql.Data.MySqlClient.MySqlCommand
maxResultSize int
Résultat string[][]
        private string[][] RunOnDatabase(MySqlCommand command, int maxResultSize)
        {
            MySqlDataReader reader = null;

            //update the last time a query has been run
            lastQuery = DateTime.Now;

            Boolean mysql_error = false;
            try
            {
                //Logger.addMessage(Logger.LogType.Info, "Executing mysql command.");
                reader = command.ExecuteReader();
            }
            catch (Exception sql_ex)
            {
                //Catch any MySQL errors (bad procedure name, missing/malformed parameters, etc.) and just return false
                //Can't use yield in a try/catch so we'll return later...
                mysql_error = true;
                Logger.addMessage(Logger.LogType.Warning, "MySQL error. " + sql_ex.ToString());
            }

            using (reader)
            {
                if (mysql_error == false)
                {
                    List<List<string>> to_return = new List<List<string>>();
                    int max_array_rows = 0;
                    while (reader.Read())
                    {
                        List<string> inner_data = new List<string>();
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            //We need to check for a null column entry here, otherwise, things explode
                            //http://stackoverflow.com/questions/1772025/sql-data-reader-handling-null-column-values
                            string value = "";
                            if (!reader.IsDBNull(i))
                            {
                                value = reader.GetString(i);
                            }

                            inner_data.Add(value);
                            //Logger.addMessage(Logger.LogType.Info, "Row value is: " + value);
                        }
                        to_return.Add(inner_data);
                        max_array_rows++;
                    }
                    reader.Close();

                    //convert into the array which we'll have to pass back
                    string[][] string_array = new string[max_array_rows][];
                    for (int i = 0; i < max_array_rows; i++)
                    {
                        string_array[i] = to_return[i].ToArray();
                    }

                    if (validLength(string_array, maxResultSize) == false)
                    {
                        return new string[][] { new[] { "TooLong" } };
                    }
                    else
                    {
                        return string_array;
                    }
                }
            }
            //Logger.addMessage(Logger.LogType.Info, "Returning error from RunProcedure");
            return new string[][] { new[] { "Error" } };
        }