title: problem converting a regular query to parametrized query
body: <p>I came across this old piece of code that looks like this:</p>
  
  <pre><code>        Dim sql As String = "exec wa_vterm_Insert_upd_Purchase_Card @merchant_id = '" &amp; db.SqlSafe(sMerchantID) &amp; "'" &amp;
          ", @reference = '" &amp; db.SqlSafe(reference) &amp; "' " &amp;
          ", @national_tax = " &amp; nationalTax &amp; " " &amp;
          ", @customer_vat_number = '" &amp; db.SqlSafe(customerVatNumber) &amp; "' " &amp;
          ", @discount_amount = " &amp; discountAmount &amp; " " &amp;
          ", @duty_amount = " &amp; dutyAmount &amp; " " &amp;
          ", @vat_invoice_number = '" &amp; db.SqlSafe(vatInvoiceNumber) &amp; "' " &amp;
          ", @vat_tax_amount = " &amp; vatTaxAmount &amp; " " &amp;
          ", @vat_tax_rate = " &amp; vatTaxRate &amp; " " &amp;
          ", @destination_country_code = '" &amp; db.SqlSafe(destCountryCode) &amp; "' "
      Trace.WriteLine(sql, LogLevel.Debug)
      db.ExecuteNonQuery(sql)
  </code></pre>
  
  <p>I am converting this to parameterized query and I coded this:   </p>
  
  <pre><code> Dim cmd As New SqlCommand("wa_vterm_Insert_upd_Purchase_Card", con)
  
      cmd.CommandType = CommandType.StoredProcedure
      cmd.Parameters.Add("@merchant_id", sqlDbType:=SqlDbType.VarChar).Value = sMerchantID
      cmd.Parameters.Add("@reference", sqlDbType:=SqlDbType.VarChar).Value = reference
      cmd.Parameters.Add("@national_tax", sqlDbType:=SqlDbType.VarChar).Value = nationalTax
      cmd.Parameters.Add("@customer_vat_number", sqlDbType:=SqlDbType.VarChar).Value = customerVatNumber
      cmd.Parameters.Add("@discount_amount", sqlDbType:=SqlDbType.VarChar).Value = discountAmount
      cmd.Parameters.Add("@duty_amount", sqlDbType:=SqlDbType.VarChar).Value = dutyAmount
  
      cmd.Parameters.Add("@vat_invoice_number", sqlDbType:=SqlDbType.VarChar).Value = vatInvoiceNumber
  
      cmd.Parameters.Add(" @vat_tax_amount", sqlDbType:=SqlDbType.Decimal).Value = vatTaxAmount
  
      cmd.Parameters.Add(" @vat_tax_rate", sqlDbType:=SqlDbType.Decimal).Value = vatTaxRate
      cmd.Parameters.Add(" @destination_country_code", sqlDbType:=SqlDbType.VarChar).Value = destCountryCode
  
      Try
          cmd.Connection.Open()
          cmd.ExecuteNonQuery()
      Catch ex As Exception
          Trace.WriteLine(ex.Message &amp; ex.Source, LogLevel.Debug)
      Finally
          cmd.Connection.Close()
      End Try
  </code></pre>
  
  <p>however with the new piece of code I am getting this exception:
  "Procedure or function 'wa_vterm_Insert_upd_Purchase_Card' expects parameter '@vat_tax_amount', which was not supplied."</p>
  
  <p>I don't understand why??</p>