SqlCommand cmd = new SqlCommand("SELECT COUNT (*) FROM singleinput", con);
int count = 0;
try
{
con.Open();
object total = cmd.ExecuteScalar();
if (total != null)
{
try
{
count = Convert.ToInt32(total);
}
catch
{
count = 0;
}
}
}
catch (Exception ex)
{
MessageBox.Show("error : " + ex.Message);
}
finally
{
con.Close();
}
label1.Text = count.ToString();