title: Using SQL Parameters in ASP CLASSIC, object improperly defined error
body: <p>I am trying to protect my INSERT statement from SQL injection using Parameters, but for some reason I am getting the error: <code>Parameter object is improperly defined. Inconsistent or incomplete information was provided...</code></p>
  
  <p>Though, I have no clue what is causing it. </p>
  
  <p>My SQL statement is as follows:</p>
  
  <pre><code>Set spSQL = Server.CreateObject("ADODB.Command")
  Set spSQL.ActiveConnection = con_vhs
  vrdSQL = "INSERT INTO boekingen ([Order],[Positie],[Tariefnummer],[Relatie],[Datum],[AantalEenheden],[Omschrijving],[Bedrag],[Totaal],[Status]) VALUES (@Order,@Pos,@Tar,@Rel,@Datum,@Aantal,@Omsch,@Bedrag,@Totaal,@Status)"
  spSQL.commandtext= vrdSQL
  spSQL.Parameters.Append(spSQL.CreateParameter("@Order", adInteger,,,1506))
  spSQL.Parameters.Append(spSQL.CreateParameter("@Pos", adVarWChar,,10,"0"))
  spSQL.Parameters.Append(spSQL.CreateParameter("@Tar", adVarWChar,,50,"VRD"))
  spSQL.Parameters.Append(spSQL.CreateParameter("@Rel", adInteger,,,4020))
  spSQL.Parameters.Append(spSQL.CreateParameter("@Datum", adDate,,,iDatumTotaal))
  spSQL.Parameters.Append(spSQL.CreateParameter("@Aantal", adSingle,,,"5,25"))
  spSQL.Parameters.Append(spSQL.CreateParameter("@Omsch", adVarWChar,,150,OmschrijvingGoed))
  spSQL.Parameters.Append(spSQL.CreateParameter("@Bedrag", adDecimal,,,sBedrag))
  spSQL.Parameters.Append(spSQL.CreateParameter("@Totaal", adDecimal,,,sTotaal))
  spSQL.Parameters.Append(spSQL.CreateParameter("@Status", adInteger,,,StatusVRD))
  
  Dim oPrm
  For Each oPrm In spSQL.Parameters
      If oPrm.Type = adDecimal Then
          oPrm.NumericScale = 2
          oPrm.Precision = 17
      End If
  Next
  set rst= spSQL.execute(vrdSQL)
  </code></pre>
  
  <p>Some parameters values are set hard-coded (just for test purposes) and some are set using variables. I am getting the error however already on the first append parameter line.. What am I doing wrong? </p>
  
  <p>Some additional information: </p>
  
  <ul>
  <li>I am inserting the data into a SQL 2012 Server. </li>
  <li>The types in the SQL server are as follows:</li>
  </ul>
  
  <pre><code>@Order = int &lt;br/&gt;
  @Pos = nvarchar(10) &lt;br/&gt;
  @Tar = nvarchar(50) &lt;br/&gt;
  @Rel = int &lt;br/&gt;
  @Datum = datetime2(0) &lt;br/&gt;
  @Aantal = real &lt;br/&gt;
  @Omsch = nvarchar(150) &lt;br/&gt;
  @Bedrag = money (will be changed to Decimal(17,2) soon &lt;br/&gt;
  @Totaal = money (will be changed to Decimal(17,2) soon) &lt;br/&gt;
  @Status = int
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <pre><code>Set spSQL = Server.CreateObject("ADODB.Command")
  Set spSQL.ActiveConnection=con_vhs
  spSQLCommandType = adCmdText
  vrdSQL="INSERT INTO boekingen ([Order],[Positie],[Tariefnummer],[Relatie],[Datum],[AantalEenheden],[Omschrijving],[Bedrag],[Totaal],[Status]) VALUES (?,?,?,?,?,?,?,?,?,?)"
  spSQL.commandtext= vrdSQL
  spSQL.Parameters.Append spSQL.CreateParameter("@Order", adInteger,adParamInput,4)
  spSQL.Parameters.Append spSQL.CreateParameter("@Positie", adVarWChar,adParamInput,10)
  spSQL.Parameters.Append spSQL.CreateParameter("@Tariefnummer", adVarWChar,adParamInput,50)
  spSQL.Parameters.Append spSQL.CreateParameter("@Relatie", adInteger,adParamInput,4)
  spSQL.Parameters.Append spSQL.CreateParameter("@Datum", adDate,adParamInput,0)
  spSQL.Parameters.Append spSQL.CreateParameter("@AantalEenheden", adSingle,adParamInput,4)
  spSQL.Parameters.Append spSQL.CreateParameter("@Omschrijving", adVarWChar,adParamInput,150)
  spSQL.Parameters.Append spSQL.CreateParameter("@Bedrag", adDecimal,adParamInput,0)
  spSQL.Parameters.Append spSQL.CreateParameter("@Totaal", adDecimal,adParamInput,0)
  spSQL.Parameters.Append spSQL.CreateParameter("@Status", adInteger,adParamInput,4)
  spSQL.Parameters("@Order").Value = 1506
  spSQL.Parameters("@Positie").Value = "0"
  spSQL.Parameters("@Tariefnummer").Value = "VRD"
  spSQL.Parameters("@Relatie").Value = 4020
  spSQL.Parameters("@Datum").Value = iDatumTotaal
  spSQL.Parameters("@AantalEenheden").Value = TestAantal
  spSQL.Parameters("@Omschrijving").Value = OmschrijvingGoed
  spSQL.Parameters("@Bedrag").Value = sBedrag
  spSQL.Parameters("@Totaal").Value = sTotaal
  spSQL.Parameters("@Status").Value = StatusVRD
  
  Dim oPrm
  For Each oPrm In spSQL.Parameters
      If oPrm.Type = adDecimal Then
          oPrm.NumericScale = 2
          oPrm.Precision = 17
      End If
  Next
  set rst= spSQL.execute(vrdSQL)
  </code></pre>
  
  <p>Update 2, Removed the parenthesis around the <code>.append</code> and added the right size values in the parameters. Still getting the error:</p>
  
  <p><code>Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.. . ON spSQL.Parameters.Append spSQL.CreateParameter("@Order", adInteger,adParamInput,4)</code></p>
  
  <p><strong>UPDATE 3</strong></p>
  
  <p>This update was after inserting the meta tag in my global.asa file. </p>
  
  <p>I updated my global.asa file with the following:</p>
  
  <pre><code>&lt;!-- METADATA TYPE="typelib" UUID="00000200-0000-0010-8000-00AA006D2EA4" --&gt;
  </code></pre>
  
  <p>The global.asa file now looks as follows: </p>
  
  <pre><code>&lt;script language="VBScript" runat="Server"&gt;
      Sub Session_OnStart()
          &lt;!-- METADATA TYPE="typelib" UUID="00000200-0000-0010-8000-00AA006D2EA4" --&gt;
  
          Session.Timeout = 480
      End Sub
  &lt;/script&gt;
  </code></pre>
  
  <p>The code of the parameters remained the same. Now I am getting (happily) a different error on the execute:</p>
  
  <p><code>[Microsoft][ODBC SQL Server Driver]Optional feature not implemented. . ON set rst= spSQL.execute(vrdSQL)</code> </p>