You probably have forgotten to write your problem in the question.
Looking at your code, it has following mistakes
1. Query seems to be incorrect
select count(*) from old_patient where Contact_no=@Contact_no GROUP BY Contact_no
It should be-
select count(*) from old_patient where Contact_no=@Contact_no
2. You should use ExecuteScalar instead of ExecuteNonQuery
int rec = (int)vst.ExecuteNonQuery();
it should be-
int rec = (int)vst.ExecuteScalar();
Here is a detailed article for detailed reading-
Difference between ExecuteReader ExecuteScalar and ExecuteNonQuery[
^]
Hope, it helps :)
If you find further difficulties, please let me know.