Find lowest mark from student table to label using c# [Resolved]

Posted by Kundan under C# on 8/31/2013 | Points: 10 | Views : 2132 | Status : [Member] | Replies : 3
Find lowest mark from student table to label using c#




Responses

Posted by: Bandi on: 8/31/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
to find out lowest mark of student table you can query as follows:
1)
select top 1 salary from student order by salary asc;

2) by using aggregate function
select min(salary) from student;

then assign result of above query to label
Label1.Text = com.ExecuteScalar()



Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Kundan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 9/3/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi

try this

Create Proc TestQry
as
Select TOP(1) Salary,Department from employee group BY Department,salary order BY Salary


SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{

}
protected void bt1_Click(object sender, EventArgs e)
{
try
{
con.Open();
SqlCommand sqlcmd = new SqlCommand("TestQry", con);
lblMin.Text = " Min Salary : " + Convert.ToDecimal(sqlcmd.ExecuteScalar()).ToString();
}
catch (Exception ex)
{

}

}

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com

Kundan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Venky.Net on: 9/3/2013 [Member] Starter | Points: 25

Up
0
Down
1.first create proceudre
create procedure proc_minasalary
as
begin
select min(salary) from salary
end
2.call procedure name on your code behind page

datatable dt=controller.getnamedetailtodataset("minsalary");
label1.text=dt.rows[0][0].tostring();




Kundan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response