Populate graph with mysql data

1

I am developing a C # application and need to fill in a graph with the amount of data registered in 3 MySql tables. It is as follows: The graph should inform the user in different columns how much data are registered in the product tables, logsentrada and logssaida respectively, as in the image below:

Ihavethedifficultyofmakingthispossible.Hereistheimagewiththegraphicintheform:

ConnectionString:

publicclassDadosDaConexao{publicstaticStringservidor="%";
    public static String banco = "estoque_box";
    public static String usuario = "estBox";
    public static String senha = "estoqueBox";
    public static String StringDeConexao
    {
        get
        {
            return "Server=" + servidor + ";Database=" + banco + ";Uid=" + usuario + ";Pwd=" + senha;
        }
    }
}

I think this might help:

public void loadChart()
    {
        MySqlConnection conexao = new MySqlConnection();
        conexao.ConnectionString = DadosDaConexao.StringDeConexao;
        conexao.Open();
        string Query = "select count(*) from produto where pro_cod;";
        MySqlCommand cmdDataBase = new MySqlCommand(Query, conexao);
        MySqlDataReader myReader;
        try
        {
            myReader = cmdDataBase.ExecuteReader();
            while (myReader.Read())
            {
                this.GrProdutos.Series["Produto"].Points.AddXY(myReader.GetString("pro_cod"), myReader.GetString("pro_cod"));
            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        conexao.Close();
    }
    
asked by anonymous 20.12.2016 / 15:00

1 answer

1

Your error is in SQL

select count(*) from produto where pro_cod;

This is missing the cod parameter eg:

select count(*) from produto where pro_cod = 1 group by parametrodeAgrupamento;

Otherwise if you want to use the column pro_cod it should come in select,

select count(*) as count, pro_cod from produto where pro_cod = 1 group by parametrodeAgrupamento;

On the graph orientation you are adding equal values in x and y

This will not work, you need to review what you need to show in the chart Tip do not go through trial and error, read what you're doing and then do it.

use this way

myReader.GetString("count")
    
22.12.2016 / 19:55