1
I am developing an application in C# and need to fill a graph with the amount of data registered in 3 Mysql tables. It is as follows: The graphic should inform the user in different columns how many data are registered in the product tables, logged and logged respectively, as in the image below:
I have a hard time making that happen. Follow image with graph in form:
Connection string:
public class DadosDaConexao
{
public static String servidor = "%";
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();
}
Some tips: 1. do not use tag
visual-studio
if the problem is unrelated to the IDE. If you have any questions, I recommend reading: What is a programming language, IDE and compiler?; 2. Show us what you have already tried, preferably add a [mcve]; 3. Try to explain the difficulty you are having, in the current form the question is very wide and possibly will be closed so.– Jéf Bueno
I have already added to the chart, however no function has been added to it
– Marlon Pereira
When you run the query in the database, what is your method returning a Datatable ? Put there in question how you are doing the query.
– Robss70
I added the code @Robss70
– Marlon Pereira