Hello guys,
I have an issue with a database call. I'm hoping you can help me out.
I've got a database call that counts the number of entries in the database:
Afterwards I'm using this as a check throughout my application:
When I execute this code I'm getting the following error: "Operator '>' cannot be applied to operands of type 'method group' and 'int'"
So I'm guessing it has something to do with the cast of the dbCount-object but I don't understand why as I already stated that the count-object to be an Int32.
Who can point out what I've done wrong?
Thanks
I have an issue with a database call. I'm hoping you can help me out.
I've got a database call that counts the number of entries in the database:
Code:
private static Int32 dbCount()
{
SqlCommand cmd = new SqlCommand("SELECT COUNT (*) FROM Employees", conn);
conn.Open();
Int32 count = (Int32)cmd.ExecuteScalar();
conn.Close();
return count;
}
Code:
if (dbCount > 0)
{
// do something
}
So I'm guessing it has something to do with the cast of the dbCount-object but I don't understand why as I already stated that the count-object to be an Int32.
Who can point out what I've done wrong?
Thanks
Comment