I have a table, from which I am unable to select max salary.
Here is my code...
con.Open();
SqlCommand cmd = new SqlCommand("SELECT MAX(salary) AS MAximumSalary FROM test", con);
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
count =Convert.ToInt32(dt.Rows.Count.ToString());
con.Close();
MessageBox.Show("Maximum salary is" +count);
Here is my database:-
name salary
a 10000
b 31000
c 17000
using (SqlCommand cmd = new SqlCommand("SELECT MAX(salary) FROM test"), con)
{
int maxSalary = (int)cmd.ExecuteScalar();
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments