ashwini bhingole

ashwini bhingole

  • NA
  • 7
  • 15.4k

I want to count Attendance column and display on textbox

Jan 20 2012 2:59 AM
hi,

i want to count Attendancecolumn and display on textbox.i have the following code but it gives error.give me proper code as soon as possible.


public void countattedence()
  {
  OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\SJPDbase.mdb");
  con.Open();
  OleDbCommand cmd = new OleDbCommand("select count(Attendance) from dbo_Attandances where Emp_Name='" + cmbName.SelectedItem + "'", con);
  //SqlDataReader dr;
  OleDbDataReader dr;
  dr = cmd.ExecuteReader();
  while(dr.Read())
  {
  //int c = Convert.ToInt32( dr["Attendance"]);
  txtprd.Text = dr["Attendance"].ToString();
  }
  con.Close();
  }

Answers (3)