C # (windows form) progress bar using mysql data

0

I currently have this code in one of the forms of a developing application and would like to create a progress bar which, by clicking on the View button (which takes a while to populate the datagrid) would show the progress of the data.

namespace Odin
{
    public partial class frmBuscaPorNome : Form
    {
        public frmBuscaPorNome()
        {
            InitializeComponent();
        }

        Conexao bd = new Conexao();

        private void CarregarGrid()
        {
            string sql = "SELECT * FROM ebt_iw ORDER BY id;";
            dtgBusca.DataSource = bd.ExecutarConsultas(sql);
        }

        private void btnBusca_Click(object sender, EventArgs e)
        {
            string Busca = txtBusca.Text;
            string bsc = "SELECT * FROM ebt_iw WHERE nome LIKE '" + Busca + "%' ;";
            dtgBusca.DataSource = bd.ExecutarConsultas(bsc);

        }

        private void btnVer_Click(object sender, EventArgs e)
        {
            CarregarGrid();
        }

        private void btnSair_Click(object sender, EventArgs e)
        {
            Close();
        }
    }

This is the connection class:

 class Conexao
    {
        MySqlConnection conexao;

        public void Conectar()
        {
            string string_conexao = "Persist Security Info = false;server = localhost;database = ebtiw;uid = root;pwd = ;SslMode=none;";
            conexao = new MySqlConnection(string_conexao);
            conexao.Open();
        }

        public void ExecutarComandos(string sql)
        {
            Conectar();
            MySqlCommand comando = new MySqlCommand(sql, conexao);
            comando.ExecuteNonQuery();
            conexao.Close();
        }

        public DataTable ExecutarConsultas(string query)
        {
            Conectar();

            DataTable dt = new DataTable();
            MySqlDataAdapter dados = new MySqlDataAdapter(query, conexao);
            dados.Fill(dt);
            conexao.Close();

            return dt; //dt armazena os resultado obtido de execuçao do SELECT ( da string query)
        }

    }
}
    
asked by anonymous 22.08.2018 / 18:57

0 answers