Exemplo n.º 1
0
        /// <summary>
        /// Gets my SQL connection.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="password">The password.</param>
        /// <param name="server">The server.</param>
        /// <param name="port">The port.</param>
        /// <returns>System.Data.Common.DbConnection.</returns>
        public static System.Data.Common.DbConnection GetMySqlConnection(
            string database,
            string userId,
            string password,
            string server = "localhost",
            uint port     = 3306)
        {
            var connectionFactory = new MySql.Data.Entity.MySqlConnectionFactory();
            var connectionString  = MySql.Data.MySqlClient.MySqlDbContext.GetMySqlConnectionString(database, userId, password, server, port);

            return(connectionFactory.CreateConnection(connectionString));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets my SQL connection.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <returns>DbConnection.</returns>
        public static System.Data.Common.DbConnection GetMySqlConnection(string connectionString)
        {
            var connectionFactory = new MySql.Data.Entity.MySqlConnectionFactory();

            return(connectionFactory.CreateConnection(connectionString));
        }