title: SQL with ASP Syntax
body: <p>I'm testing out a sql query on a query analyzer and it works just fine, here it is:</p>
  
  <pre><code>INSERT INTO Questions(QuestionText, QuestionType)
   VALUES('test','test')
       DECLARE @testID int
          SET @testID = @@identity
           INSERT INTO Questions(QuestionText)
           VALUES (@testID)
  </code></pre>
  
  <p>(I'm just testing out the @@identity function)</p>
  
  <p>However as soon as I try and implement it on my site (i'm using SQL in conjunction with asp Classic) I get an error, can someone tell me what i'm doing wrong please? Here is what I have put in the asp:</p>
  
  <pre><code> set rs=Server.CreateObject("ADODB.recordset")
           rs.Open "Select * from Questions", conn
  
           sql="INSERT INTO Questions(QuestionText, QuestionType)"
           sql=sql &amp; " VALUES "
           sql=sql &amp; "('" &amp; qtext &amp; "',"
           sql=sql &amp; "'" &amp; "checkbox" &amp; "')" 
           sql=sql &amp; "DECLARE @testID int"
           sql=sql &amp; "SET @testID = @@identity"
           sql=sql &amp; "INSERT INTO Questions(QuestionText)"
           sql=sql &amp; " VALUES "
           sql=sql &amp; "(@testID)"
  
           on error resume next
           conn.Execute sql,recaffected
           if err&lt;&gt;0 then
           Response.Write("An Error Has Occured")
           else
  Response.write("Data Added")
           end if
  
           conn.close
  </code></pre>