read last serial number in database

Posted by Asvreddy under C# on 12/12/2012 | Points: 10 | Views : 1193 | Status : [Member] | Replies : 9
read total employes

EMP Table AS Follows;

EMPID EMPNAME MGRNo MGRNAME
1 Raj Null RAvi
2 Ram 1 Sam
3 ttt 2 ghg
4 Hari 3 Yogi

from the above EMP Table i wan the output as follows


total no of employes 4




Responses

Posted by: Naraayanan on: 12/12/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
  Select max(EMPID ) from EMP 


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

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

Posted by: Saratvaddilli on: 12/12/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi Please check this one


SELECT COUNT(EMPID ) FROM EMP  


which gives the count of total number of employees in the EMP table

   Select max(EMPID ) from EMP 


It will give only the max number of employee Id not the employees

Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

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

Posted by: Pavanandey on: 12/13/2012 [Member] Bronze | Points: 25

Up
0
Down
select count(Empid) from EMP gives you the number of employess count



Thanks
Pavan Kumar
Mark Answer if this fits the need

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

Posted by: Ranjeet_8 on: 12/13/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
check this
select count(EMPNAME) as TotalEmployee from EMP


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

Posted by: Kundnani.Rt on: 1/19/2013 [Member] Starter | Points: 25

Up
0
Down
In C#, you can do it with LINQ Extension Method:

int n=<linq-tosql-object>.Count();

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

Posted by: Asvreddy on: 1/19/2013 [Member] Starter | Points: 25

Up
0
Down
write the code in business layer plz

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

Posted by: Raja_89 on: 1/21/2013 [Member] Starter | Points: 25

Up
0
Down
Hai

select count(emp_id ) as total no of employees from emp_table

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

Posted by: Sourabh07 on: 1/21/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

Check this code

select 'total no of employes' + convert(varchar(10),COUNT(EMPID )) from dbo.eSignupUsers 





Please Mark this answer, if it resolves your problem.

Sourabh07

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

Posted by: Satyapriyanayak on: 1/21/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Count_total_empid._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btn_count" runat="server" onclick="btn_count_Click" Text="Count" /><br />
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>

</form>
</body>
</html>



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Count_total_empid
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void btn_count_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select count(*)from employee";
com = new SqlCommand(str, con);
Label1.Text = "Total no of employees::" + com.ExecuteScalar().ToString();
con.Close();
}
}
}




If this post helps you mark it as answer
Thanks

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

Login to post response