public SqlResult Select(string sql, params object[] args) { if (connection == null) return null; lock (mysqlLock) { try { using (var sqlCommand = new MySqlCommand(sql, connection)) { var mParams = new List<MySqlParameter>(args.Length); foreach (var a in args) mParams.Add(new MySqlParameter("", a)); sqlCommand.Parameters.AddRange(mParams.ToArray()); using (var sqlData = sqlCommand.ExecuteReader(CommandBehavior.Default)) { using (var retData = new SqlResult()) { retData.Load(sqlData); retData.Count = retData.Rows.Count; return retData; } } } } catch (MySqlException exception) { LogManager.Write("Database Manager", "An exception occured while selecting data from the database!"); LogManager.Write("Database Manager", "Exception: {0}", exception.Message); } } return null; }