title: Classic ASP SELECT * WHERE x AND x
body: <p>I was wondering how to properly code the strSQL line below to return correct results.</p>
  
  <pre><code>SELECT * FROM Reviews WHERE Month=x AND Year=x
  </code></pre>
  
  <p>I will hardcode in the month and year.</p>
  
  <p>I am running an asp page using an access db.  I tried the string above (with the month and year hardcoded) but it did not work.  </p>
  
  <p>The server log page is down so I cant check it that way and even though my browser is set to display the full error message, all I see is 500 - Internal Server Error.  </p>
  
  <p>I have checked the Reviews table for records matching the month and year I coded and there are quite a few for March 2012 so it should display several results.</p>
  
  <p>The month and year fields are separate fields in the database manually entered by the user.</p>
  
  <pre><code>&lt;%
  Set adoCon = Server.CreateObject("ADODB.connection")' initialize connection
  Set ors = Server.CreateObject("ADODB.RecordSet")' initialize record set
  
  adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &amp; Server.MapPath("database.mdb")
  
  Const COLUMN_COUNT = 1
  strSQL = "SELECT * FROM Reviews WHERE Month= 'March' AND Year= '2012'"
  
  coll_width=100/COLUMN_COUNT
  
  column = 0 ' initialize counter
  
  ors.open strSQL,adoCon,1,1  'open record set
  
  Do While Not ors.EOF
  If column = 0 Then Response.Write "&lt;TR&gt;" 
  
  %&gt;
  &lt;td width="&lt;%=coll_width%&gt;%" valign="top" &gt;&lt;table width="100%" border="0"&gt;
  &lt;tr    &gt; 
  &lt;td height="100%"&gt;
  &lt;div class="extra_container post reviews"&gt;
  &lt;figure&gt; &lt;img src="images/&lt;% = oRs.Fields("Image") %&gt;" width="200" alt=""&gt; &lt;/figure&gt;
  &lt;div&gt;
  &lt;div class="date"&gt;
  &lt;% = oRs.Fields("ReleaseDate") %&gt;
  &lt;/div&gt;
  &lt;div class="title"&gt;
  &lt;% = oRs.Fields("Artist") %&gt; - &lt;% = oRs.Fields("Album") %&gt;
  &lt;/div&gt;
  &lt;% = oRs.Fields("Teaser") %&gt;
  &lt;br&gt;
  &lt;a href="cdreviewsmain.asp?pl=&lt;% = oRs.Fields("ID") %&gt;" class="button"&gt;more&lt;/a&gt; &lt;/div&gt;
  &lt;/div&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;% column = column + 1 
  If column = COLUMN_COUNT Then 
  Response.Write "&lt;/TR&gt;" &amp; vbNewLine 
  column = 0 ' start over! 
  End If 
  oRS.MoveNext 
  Loop %&gt;
  &lt;% ors.Close 'Close the database connection
  'SET ors = Nothing 'Clean up after yourself
  %&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I have a couple of other problems but I will get them sorted one at a time!</p>
  
  <p>Thanks for any help you may be able to give,</p>
  
  <p>Ian</p>