3
I need to sum all the values of a column containing in each row a specific date, that is, in the database, the values are saved with the date typed in the textBox
in the act of registration, and I need to sum all the values of the column quantidadeVagas
. So when the user enters a date in the program, it returns the sum of that column with the data containing the date typed.
I did it that way but it didn’t work:
string query = "Select sum (quantidadeVagas) from vagas where data like '%" + mTxtDataVagas.Text + "%'";
MySqlConnection conexao = new MySqlConnection();
conexao.ConnectionString = DadosDaConexao.StringDeConexao;
conexao.Open();
MySqlCommand cmdDataBase = new MySqlCommand(query, conexao);
MySqlDataReader myReader;
myReader = cmdDataBase.ExecuteReader();
while (myReader.Read())
{
int quantidade = Convert.ToInt32(myReader.GetString("count"));
}
The following error appears:
What is not working? An error occurs, it does not bring the expected result? Please give more details so we can help you. If you can leave an example of the expected result and the template of your table (name of fields and example of a 2 records). Thank you.
– Pedro Paulo
I edited in more detail
– Marlon Pereira