how to make auto refresh label?
hi friends ... i want to make an auto refresh label to display a row count and auto refresh her self every some seconds? for example i have a table caled student_info it have column caled student_id i ... every student have a student_id ... i want to count number of student_ids in the table (number of students) and display it by a label in the form and every i insert new student the refresh her self and increment the number of students?

VulpesPosted Jul 28, 2013, 4:09 PM
You have to add the code I posted to whatever code you're currently using to insert or delete a student from the database. The count shown in the label will then be adjusted without the need to keep getting this from the database.
However, if you'd prefer to get it from the database after each change, then call Sanjeeb's method instead.
Sanjeeb LenkaPosted Jul 28, 2013, 3:00 PM
{
string connString = "Your connection string";
string sql = "SELECT COUNT(student_id) FROM student_info";
using (SqlConnection conn = new SqlConnection(connString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
try
{
conn.Open();
count = (int)cmd.ExecuteScalar();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
label1.Text = count.ToString();
}
call this method in Form load, Within Insert new student button click if successfully inserted,
Within Delete student button click if successfully deleted
honar abubakrPosted Jul 28, 2013, 2:48 PM
VulpesPosted Jul 28, 2013, 10:58 AM
honar abubakrPosted Jul 28, 2013, 9:30 AM
Iftikar HussainPosted Jul 28, 2013, 6:17 AM
Are you looking for in ASP.NET?
Regards,
Iftikar