title: put SELECT COUNT(*) statement result into int variable
body: <p>I have a <code>SELECT COUNT(*)</code> statement in <code>C#/ASP.NET</code> and I want to store the result as an <code>int</code> to use as an <code>IF</code> condition. However I am getting an error in visual studio: </p>
  
  <blockquote>
    <p>Error:System.Data.SqlClient.SqlException (0x80131904): The data types text and varchar are incompatible in the equal to operator. at System.Data.SqlClient.SqlConnection.</p>
  </blockquote>
  
  <p>It tells me its occurring at the <strong>int temp</strong> line. The columns I'm accessing in the database table are of text type.</p>
  
  <pre><code>conn.Open();    
  String checkEmail = "select count(*) from Players where PlayerEmail= '" + txtEmailLogIn.Text + "'";
  SqlCommand com = new SqlCommand(checkEmail, conn);
  int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
  conn.Close();
  if (temp &gt; 0) 
  {
  
  }
  </code></pre>