If there is no result in the table it should return zero, but currently, it is returning -1. I build my logic that if there is zero do this and if it is not zero mean record exist to do this. I am new to C# and SQL Server. Kindly let me know if there is any mistake in my code.
int UserExist = 0;
using (SqlCommand cmd1 = new SqlCommand(@"select DISTINCT max(billno) AS bill from sale where ([date]='" + bildt.Text + "') ", con)) {
UserExist = (int)cmd1.ExecuteNonQuery();
if (UserExist > 0) {
do this
} else {
do some thing
}
}