I am trying to get the row data from the database table to a label the condition is I want the highest value column to be displayed in the label with other fields currently my code is :
private void electionWinner()
{
try
{
conn.Open();
string qry = "SELECT * FROM Results WHERE (SELECT MAX(Results) FROM Results) ";
SqlCommand cmd = new SqlCommand(qry,conn);
string result = cmd.ExecuteReader().ToString();
winnerlbl.Text = result.ToString();
}
catch (SqlException es)
{
MessageBox.Show($"{es}");
}
}
}
I am currently new to c# and trying to understand it, so I am lost, thanks in advance.