title: Debugging a vb.net SQL command
body: <p>I am attempting to call SQL stored procedure that does an INSERT. However, when I walkthrough my vb.net code, I get a message saying <strong>"Procedure or function sp_InsertARPlanner has too many arguments specified."</strong>  </p>
  
  <p>I have double checked, but the SQL string in VB has the same # of params as in the stored procedure.  </p>
  
  <p>Any ideas how I can debug this?  </p>
  
  <p><strong>Update</strong>  </p>
  
  <pre><code>    SQLCmd.CommandText = "sp_InsertARPlanner"
      SQLCmd.CommandType = CommandType.StoredProcedure
  
  SQLCmd.Parameters.AddWithValue("@Origin", Trim(txtOrigin.Text))
  SQLCmd.Parameters.AddWithValue("@Destination", Trim(txtDest.Text))
  SQLCmd.Parameters.AddWithValue("@Miles", iMiles)
  SQLCmd.Parameters.AddWithValue("@Rate", iAvgRateperMile)
  SQLCmd.Parameters.AddWithValue("@MinCost", dMinCost)
  SQLCmd.Parameters.AddWithValue("@Zone", sZone)
  SQLCmd.Parameters.AddWithValue("@LaneHaulCost", dLaneHaulCost)
  SQLCmd.Parameters.AddWithValue("@TotalCost", dTotalCost)              
  SQLCmd.Parameters.AddWithValue("@TotalWithSurch", dTotalWithSurch)
  SQLCmd.Parameters.AddWithValue("@AvgTypeRate", sAvgTypeRate)    
  SQLCmd.Parameters.AddWithValue("@AvgLoads", sAvgLoads)          
  SQLCmd.Parameters.AddWithValue("@FuelLevel", dFuelPercent)    
  SQLCmd.Parameters.AddWithValue("@Fuel", dFuelAmount)      
  SQLCmd.Parameters.AddWithValue("@AverageRateAmount", dAverageRateAmount)
  SQLCmd.Parameters.AddWithValue("@Floor", decFloor)
  SQLCmd.Parameters.AddWithValue("@RainBulkRate", decBulkRate)
  SQLCmd.Parameters.AddWithValue("@RateComments", txtRateDesc..Text)
  SQLCmd.Parameters.AddWithValue("@PremiumField", txtPremium.Text)
  SQLCmd.Parameters.AddWithValue("@EquipCategory", Trim(cboEquipType.Text))
  SQLCmd.Parameters.AddWithValue("@UpdateDate", DateTime.Now)
  SQLCmd.Parameters.AddWithValue("@FreightDesc", "txtFreightDesc.Text")
  
  Try
      SQLCmd.ExecuteNonQuery()
  Catch ex As Exception
      MsgBox(ex.Message)
      SQLCon.Close()
      SQLCmd.Parameters.Clear()
      Exit Sub
  End Try  
  </code></pre>
  
  <hr>
  
  <pre><code>ALTER PROCEDURE [dbo].[sp_InsertARPlanner]
      (@Origin nvarchar(150)
             ,@Destination nvarchar(150)
             ,@Miles nvarchar(50)
             ,@Rate nvarchar(5)
             ,@MinCost decimal(5,2)
             ,@Zone varchar(3)
             ,@LaneHaulCost decimal(5, 2)
             ,@TotalCost decimal(5, 2)
             ,@TotalWithSurch decimal(5, 2)
             ,@AvgTypeRate varchar(50)
             ,@AvgLoads varchar(4)
             ,@FuelPercent decimal(5,2)
             ,@FuelAmount decimal(5,2)
             ,@AverageRateAmount decimal(5,2)
             ,@Floor decimal(5, 2)
             ,@RainBulkRate decimal(5, 2)
             ,@RateComments nvarchar(50)
             ,@PremiumField nvarchar(50)
             ,@EquipCategory nvarchar(50)
             ,@UpdateDate datetime
             ,@FreightDesc nvarchar(50))
  </code></pre>