Пример #1
0
        public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)
        {
            //create & open a SqlConnection
            var cn = new MySqlConnection(connectionString);

            cn.CheckAndOpen();

            try
            {
                //call the private overload that takes an internally owned connection in place of the connection string
                return(ExecuteReader(cn, null, commandText, CommandType.Text, commandParameters, false));
            }
            catch
            {
                //if we fail to return the SqlDatReader, we need to close the connection ourselves
                cn.Close();
                throw;
            }
        }