title: SQL Statement "invalid column name": how to build query?
body: <pre><code>    string ID = "";
          if (Session["sID"] != null)
          {
              ID = Session["sID"].ToString();
              con.Open();
  
              string surveysr = "Select ShowResult from Survey where SurveyID=" + ID ;
              SqlCommand cmd2 = new SqlCommand(surveysr, con);
              SqlDataReader dr = cmd2.ExecuteReader();
             .............
  </code></pre>
  
  <p>the error given was " Invalid column name 'S29' "
  the problem was, the ID is just S29, without the single quote.
  however, when the sql catch is with the ''.
  any idea??</p>