-1
I have no idea how I’m going to handle the data, so far what I’ve tried to accomplish is this code:
public void loadChart()
{
MySqlConnection conexao = new MySqlConnection();
conexao.ConnectionString = "Server=localhost;Database=db_softaurus;Uid=root;Pwd=usbw;";
conexao.Open();
string Query = "select genero_animal, Count(1) as Total from tb_animal group by genero_animal";
MySqlCommand cmdDataBase = new MySqlCommand(Query, conexao);
MySqlDataReader myReader;
try
{
myReader = cmdDataBase.ExecuteReader();
while (myReader.Read())
{
chart1.Series["Macho"].Points.AddXY(myReader.GetString("genero_animal"));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}`
I wanted to return the sex of the animal separated by male and female on the chart
I don’t understand, exactly, what is your doubt? what is the error presented?
– Leandro Angelo
So I wanted to display on the graph the amount of animals of the male gender and the female gender, but I have no idea how to do this, I tried to do with this code but, it didn’t work very well
– Enzo da Costa Xavier
You can start by changing your query, taking out the
Where genero_animal = 'M'
and replacing byselect genero_animal, Count(1) as Total, from tb_animal Group By genero_animal
– Leandro Angelo
In the case here gave Syntax error
– Enzo da Costa Xavier
Is that now you need to change the rest of the code...
– Leandro Angelo
I got it. what I do now?
– Enzo da Costa Xavier
It depends, what did you do? Edit the question by updating your progress.
– Leandro Angelo
I changed the query, but I don’t know what I should do to be able to insert this query data in the chart
– Enzo da Costa Xavier