Ejemplo n.º 1
0
 public MySqlField(MySqlConnection connection)
 {
     this.connection = connection;
     this.connVersion = connection.driver.Version;
     this.maxLength = 1;
     this.binaryOk = true;
 }
Ejemplo n.º 2
0
 public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters)
 {
     using (MySqlConnection connection = new MySqlConnection(connectionString))
     {
         connection.Open();
         return ExecuteDataset(connection, commandText, commandParameters);
     }
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
		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 );
				}
			}
		}
Ejemplo n.º 5
0
 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)));
         }
     }
 }
Ejemplo n.º 6
0
 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];
 }
Ejemplo n.º 7
0
 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];
 }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 9
0
 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;
 }
Ejemplo n.º 10
0
		public MySqlPromotableTransaction( MySqlConnection connection, Transaction baseTransaction ) {
			this.connection = connection;
			this.baseTransaction = baseTransaction;
		}
Ejemplo n.º 11
0
		internal MySqlTransaction( MySqlConnection c, System.Data.IsolationLevel il ) {
			mConnection = c;
			mLevel = il;
			mOpen = true;
		}
Ejemplo n.º 12
0
 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;
     }
 }
Ejemplo n.º 13
0
		/// <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;
		}
Ejemplo n.º 14
0
 public UsageAdvisor(MySqlConnection conn)
 {
     this.conn = conn;
 }
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 16
0
		object ICloneable.Clone() {
			MySqlConnection connection = new MySqlConnection();
			string connectionString = this.settings.GetConnectionString( true );
			if( connectionString != null )
				connection.ConnectionString = connectionString;
			return connection;
		}
Ejemplo n.º 17
0
 public MySqlScript(MySqlConnection connection, string query) : this()
 {
     this.connection = connection;
     this.query = query;
 }
Ejemplo n.º 18
0
 public override void Configure(MySqlConnection conn)
 {
     base.Configure(conn);
     this.stream.MaxPacketSize = (ulong) base.maxPacketSize;
     this.stream.Encoding = base.Encoding;
 }
Ejemplo n.º 19
0
 public static DataSet ExecuteDataset(MySqlConnection connection, string commandText)
 {
     return ExecuteDataset(connection, commandText, null);
 }
Ejemplo n.º 20
0
 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();
 }
Ejemplo n.º 21
0
 public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)
 {
     using (MySqlConnection connection = new MySqlConnection(connectionString))
     {
         connection.Open();
         return ExecuteScalar(connection, commandText, commandParameters);
     }
 }
Ejemplo n.º 22
0
 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;
 }
Ejemplo n.º 23
0
 public static object ExecuteScalar(MySqlConnection connection, string commandText)
 {
     return ExecuteScalar(connection, commandText, null);
 }
Ejemplo n.º 24
0
 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;
 }
Ejemplo n.º 25
0
 public MySqlScript(MySqlConnection connection) : this()
 {
     this.connection = connection;
 }
Ejemplo n.º 26
0
		public MySqlDataAdapter( string selectCommandText, MySqlConnection connection )
			: this() {
			this.SelectCommand = new MySqlCommand( selectCommandText, connection );
		}
Ejemplo n.º 27
0
		public static void ClearPool( MySqlConnection connection ) {
			MySqlPoolManager.ClearPool( connection.Settings );
		}
Ejemplo n.º 28
0
 public static int ExecuteNonQuery(string connectionString, string commandText, params MySqlParameter[] parms)
 {
     using (MySqlConnection connection = new MySqlConnection(connectionString))
     {
         connection.Open();
         return ExecuteNonQuery(connection, commandText, parms);
     }
 }
Ejemplo n.º 29
0
 public ISSchemaProvider(MySqlConnection connection) : base(connection)
 {
 }
Ejemplo n.º 30
0
        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");
        }