public bool DirectExecute(PreparedStatement stmt) { try { using (var Connection = _connectionInfo.GetConnection()) { Connection.Open(); using (MySqlCommand cmd = Connection.CreateCommand()) { cmd.CommandText = stmt.CommandText; cmd.Prepare(); foreach (var parameter in stmt.Parameters) { cmd.Parameters.AddWithValue("@" + parameter.Key, parameter.Value); } cmd.ExecuteNonQuery(); return(true); } } } catch (MySqlException ex) { HandleMySQLException(ex, stmt.CommandText, stmt.Parameters); return(false); } }
public MySqlErrorCode Initialize(MySqlConnectionInfo connectionInfo, int asyncThreads = 1) { _connectionInfo = connectionInfo; _worker = new DatabaseWorker <T>(_queue, this, asyncThreads); try { using (var connection = _connectionInfo.GetConnection()) { connection.Open(); Loggers.Server?.Info($"Connected to MySQL(ver: {connection.ServerVersion}) Database: {_connectionInfo.Database}"); return(MySqlErrorCode.None); } } catch (MySqlException ex) { return(HandleMySQLException(ex)); } }