Hi Dear Friends...!!!

I am developing a Attendance System in C# using MS Access Database.

I want to Count the totall P and A in the Attendance Column...

now Dear Friends Please tell me any Query or logic to do the above work...!!!

***P for Present***
***A for Absent ***

str="Select count(*) from TableName where Attendance='A'";
str1="Select count(*) from TableName where Attendance='P'";

Thanx Dear Friend for the Quick Reply...

But i have a Problem... :(

i use ur query like

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\employees.mdb";


            database = new OleDbConnection(connectionString);
            database.Open();

            string queryString = "select * from emp_attandence";

            loadDataGrid(queryString);

            string emp_commnd = "Select count(*) from emp_attandence where Attandence='A'";

            OleDbCommand commd = new OleDbCommand(emp_commnd, database);

            int count = commd.ExecuteNonQuery();

            MessageBox.Show("Total A are: "+count);

but im not receiving required output

it gives me this out put

"Total A are: 0" :(

I have also attached the snapshot, in which i have three A's.

Attachments result.jpg 82.78 KB

Use ExecuteScalar method.

string emp_commnd = "Select count(*) from emp_attandence where 
                          Attandence='A'";
 OleDbCommand commd = new OleDbCommand(emp_commnd, 
                                                              database);
  int count =  (int)commd.ExecuteScalar();

THANK YOU
my

DEAR DEAR DEAR Friend... u really Helped me alot... u r GENIUS. :)

PROBLEM SOLVED...!!!:cool:

This question has already been answered. Start a new discussion instead.