I m trying to count the rows where SomeColumn=SomeValue. My code is shown below. It shows nothing.
using (SqlConnection conn = new SqlConnection("ConnectionString"))
{
conn.Open();
string selectStatement = "Select count(*) from Jobs where 'JobCategory=cse'";
SqlCommand cmd = new SqlCommand(selectStatement, conn);
int count = (int)cmd.ExecuteScalar();
Label1.Text = count.ToString();
conn.Close();
What step should I take?
Your single quotes are in wrong place. Try like this;
And please parameterize your sql query always. This could be reason on SQL Injection attack. Here how you can use it;
In your case, it should be like;