public MySqlField(MySqlConnection connection) { this.connection = connection; this.connVersion = connection.driver.Version; this.maxLength = 1; this.binaryOk = true; }
public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters) { using (MySqlConnection connection = new MySqlConnection(connectionString)) { connection.Open(); return ExecuteDataset(connection, commandText, commandParameters); } }
internal MySqlDataReader(MySqlCommand cmd, PreparableStatement statement, CommandBehavior behavior) { this.command = cmd; this.connection = this.command.Connection; this.commandBehavior = behavior; this.driver = this.connection.driver; this.affectedRows = -1L; this.statement = statement; this.nextResultDone = false; this.fieldHashCS = new Hashtable(); this.fieldHashCI = new Hashtable(StringComparer.InvariantCultureIgnoreCase); }
public PerformanceMonitor( MySqlConnection connection ) { this.connection = connection; if( connection.Settings.UsePerformanceMonitor && ( procedureHardQueries == null ) ) { string perfMonCategoryName = Resources.PerfMonCategoryName; try { procedureHardQueries = new PerformanceCounter( perfMonCategoryName, "HardProcedureQueries", false ); procedureSoftQueries = new PerformanceCounter( perfMonCategoryName, "SoftProcedureQueries", false ); } catch( Exception exception ) { Logger.LogException( exception ); } } }
internal static void InitCollections(MySqlConnection connection) { MySqlCommand command = new MySqlCommand("SHOW CHARSET", connection); using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { defaultCollations.Add(reader.GetString(0), reader.GetString(2)); maxLengths.Add(reader.GetString(0), Convert.ToInt32(reader.GetValue(3))); } } }
internal static string GetDefaultCollation(string charset, MySqlConnection connection) { lock (defaultCollations) { if (defaultCollations.Count == 0) { InitCollections(connection); } } if (!defaultCollations.ContainsKey(charset)) { return null; } return defaultCollations[charset]; }
internal static int GetMaxLength(string charset, MySqlConnection connection) { lock (defaultCollations) { if (maxLengths.Count == 0) { InitCollections(connection); } } if (!maxLengths.ContainsKey(charset)) { return 1; } return maxLengths[charset]; }
public static int ExecuteNonQuery(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters) { MySqlCommand command = new MySqlCommand(); command.Connection = connection; command.CommandText = commandText; command.CommandType = CommandType.Text; if (commandParameters != null) { foreach (MySqlParameter parameter in commandParameters) { command.Parameters.Add(parameter); } } int num = command.ExecuteNonQuery(); command.Parameters.Clear(); return num; }
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters) { MySqlCommand selectCommand = new MySqlCommand(); selectCommand.Connection = connection; selectCommand.CommandText = commandText; selectCommand.CommandType = CommandType.Text; if (commandParameters != null) { foreach (MySqlParameter parameter in commandParameters) { selectCommand.Parameters.Add(parameter); } } MySqlDataAdapter adapter = new MySqlDataAdapter(selectCommand); DataSet dataSet = new DataSet(); adapter.Fill(dataSet); selectCommand.Parameters.Clear(); return dataSet; }
public MySqlPromotableTransaction( MySqlConnection connection, Transaction baseTransaction ) { this.connection = connection; this.baseTransaction = baseTransaction; }
internal MySqlTransaction( MySqlConnection c, System.Data.IsolationLevel il ) { mConnection = c; mLevel = il; mOpen = true; }
public override void Close() { if (this.isOpen) { bool flag = (this.commandBehavior & CommandBehavior.CloseConnection) != CommandBehavior.Default; this.commandBehavior = CommandBehavior.Default; this.connection.Reader = null; if (!this.nextResultDone) { while (this.NextResult()) { } } this.command.Close(); if (flag) { this.connection.Close(); } this.command = null; this.connection = null; this.isOpen = false; } }
/// <summary> /// Method to set the <see cref="mConnectionString"/> and <see cref="mConnection"/> /// <para>Also, the Connection will be Opened and Closed afterwards</para> /// </summary> public MysqlError Prepare() { MysqlError result = MysqlError.None; mConnectionString = String.Format( "SERVER={0};PORT={1};UID={2};PASSWORD={3};DATABASE={4};", mServer, mPort, mUser, mPassword, mDatabase ); mConnection = new MySqlConnection( mConnectionString ); result = Open(); if( result == MysqlError.None ) result = Close( false ); return result; }
public UsageAdvisor(MySqlConnection conn) { this.conn = conn; }
public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters) { MySqlDataReader reader; MySqlConnection connection = new MySqlConnection(connectionString); connection.Open(); try { reader = ExecuteReader(connection, null, commandText, commandParameters, false); } catch { connection.Close(); throw; } return reader; }
object ICloneable.Clone() { MySqlConnection connection = new MySqlConnection(); string connectionString = this.settings.GetConnectionString( true ); if( connectionString != null ) connection.ConnectionString = connectionString; return connection; }
public MySqlScript(MySqlConnection connection, string query) : this() { this.connection = connection; this.query = query; }
public override void Configure(MySqlConnection conn) { base.Configure(conn); this.stream.MaxPacketSize = (ulong) base.maxPacketSize; this.stream.Encoding = base.Encoding; }
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText) { return ExecuteDataset(connection, commandText, null); }
public static void UpdateDataSet(string connectionString, string commandText, DataSet ds, string tablename) { MySqlConnection connection = new MySqlConnection(connectionString); connection.Open(); MySqlDataAdapter adapter = new MySqlDataAdapter(commandText, connection); new MySqlCommandBuilder(adapter).ToString(); adapter.Update(ds, tablename); connection.Close(); }
public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters) { using (MySqlConnection connection = new MySqlConnection(connectionString)) { connection.Open(); return ExecuteScalar(connection, commandText, commandParameters); } }
public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters) { MySqlCommand command = new MySqlCommand(); command.Connection = connection; command.CommandText = commandText; command.CommandType = CommandType.Text; if (commandParameters != null) { foreach (MySqlParameter parameter in commandParameters) { command.Parameters.Add(parameter); } } object obj2 = command.ExecuteScalar(); command.Parameters.Clear(); return obj2; }
public static object ExecuteScalar(MySqlConnection connection, string commandText) { return ExecuteScalar(connection, commandText, null); }
private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn) { MySqlDataReader reader; MySqlCommand command = new MySqlCommand(); command.Connection = connection; command.Transaction = transaction; command.CommandText = commandText; command.CommandType = CommandType.Text; if (commandParameters != null) { foreach (MySqlParameter parameter in commandParameters) { command.Parameters.Add(parameter); } } if (ExternalConn) { reader = command.ExecuteReader(); } else { reader = command.ExecuteReader(CommandBehavior.CloseConnection); } command.Parameters.Clear(); return reader; }
public MySqlScript(MySqlConnection connection) : this() { this.connection = connection; }
public MySqlDataAdapter( string selectCommandText, MySqlConnection connection ) : this() { this.SelectCommand = new MySqlCommand( selectCommandText, connection ); }
public static void ClearPool( MySqlConnection connection ) { MySqlPoolManager.ClearPool( connection.Settings ); }
public static int ExecuteNonQuery(string connectionString, string commandText, params MySqlParameter[] parms) { using (MySqlConnection connection = new MySqlConnection(connectionString)) { connection.Open(); return ExecuteNonQuery(connection, commandText, parms); } }
public ISSchemaProvider(MySqlConnection connection) : base(connection) { }
public static MySqlDbType NameToType(string typeName, bool unsigned, bool realAsFloat, MySqlConnection connection) { switch (typeName.ToLower(CultureInfo.InvariantCulture)) { case "char": return MySqlDbType.String; case "varchar": return MySqlDbType.VarChar; case "date": return MySqlDbType.Date; case "datetime": return MySqlDbType.DateTime; case "numeric": case "decimal": case "dec": case "fixed": if (connection.driver.Version.isAtLeast(5, 0, 3)) { return MySqlDbType.NewDecimal; } return MySqlDbType.Decimal; case "year": return MySqlDbType.Year; case "time": return MySqlDbType.Time; case "timestamp": return MySqlDbType.Timestamp; case "set": return MySqlDbType.Set; case "enum": return MySqlDbType.Enum; case "bit": return MySqlDbType.Bit; case "tinyint": if (!unsigned) { return MySqlDbType.Byte; } return MySqlDbType.UByte; case "bool": case "boolean": return MySqlDbType.Byte; case "smallint": if (!unsigned) { return MySqlDbType.Int16; } return MySqlDbType.UInt16; case "mediumint": if (unsigned) { return MySqlDbType.UInt24; } return MySqlDbType.Int24; case "int": case "integer": if (unsigned) { return MySqlDbType.UInt32; } return MySqlDbType.Int32; case "serial": return MySqlDbType.UInt64; case "bigint": if (!unsigned) { return MySqlDbType.Int64; } return MySqlDbType.UInt64; case "float": return MySqlDbType.Float; case "double": return MySqlDbType.Double; case "real": if (!realAsFloat) { return MySqlDbType.Double; } return MySqlDbType.Float; case "text": return MySqlDbType.Text; case "blob": return MySqlDbType.Blob; case "longblob": return MySqlDbType.LongBlob; case "longtext": return MySqlDbType.LongText; case "mediumblob": return MySqlDbType.MediumBlob; case "mediumtext": return MySqlDbType.MediumText; case "tinyblob": return MySqlDbType.TinyBlob; case "tinytext": return MySqlDbType.TinyText; case "binary": return MySqlDbType.Binary; case "varbinary": return MySqlDbType.VarBinary; } throw new MySqlException("Unhandled type encountered"); }