title: Using Stored Procedure in Classical ASP .. execute and get results
body: <p>I tried to solve this all day long but it doesn't seem to work for me. I would like to execute a command and get the result back to a recordset.</p>
  <p>The problem is one of two things: either I'm getting an empty response or there is a problem with my code. I know for sure that this command should fetch few lines from the DB. I added <code>response.write</code> inside the loop, but they are never printed.</p>
  <p>Here is the code:</p>
  <pre class="lang-vbs prettyprint-override"><code>Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
  conn.open &quot;PROVIDER=SQLOLEDB;DATA SOURCE=X;DATABASE=Y;UID=Z;PWD=W;&quot;
  Set objCommandSec = CreateObject(&quot;ADODB.Command&quot;)
  With objCommandSec
      Set .ActiveConnection = Conn
      .CommandType = 4
      .CommandText = &quot;usp_Targets_DataEntry_Display&quot;
      .Parameters.Append .CreateParameter(&quot;@userinumber &quot;, 200, 1, 10, inumber)
      .Parameters.Append .CreateParameter(&quot;@group &quot;, 200, 1, 50, &quot;ISM&quot;)
      .Parameters.Append .CreateParameter(&quot;@groupvalue&quot;, 200, 1, 50, ismID)
      .Parameters.Append .CreateParameter(&quot;@targettypeparam &quot;, 200, 1, 50, targetType)
  End With 
      
  set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;) 
  rs = objCommandSec.Execute
  
  while not rs.eof
      response.write (1)
      response.write (rs(&quot;1_Q1&quot;))
      rs.MoveNext
  wend
  response.write (2)
  </code></pre>
  <p><strong>EDITED</strong>
  After revising the code, following @Joel Coehoorn answer, the solution is:</p>
  <pre class="lang-vb prettyprint-override"><code>set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;) 
  rs.oppen objCommandSec
  </code></pre>
  <p>instead of...</p>
  <pre class="lang-vbs prettyprint-override"><code>set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;) 
  rs = objCommandSec.Execute
  </code></pre>