Reputation: 1
I'm facing a problem where I was prompted that I'm passing too many parameters even though I defined it to both stored proc (SQL Server) and VB.NET:
ERROR:
System.Runtime.InteropServices.COMException: 'Procedure or function pro_SearchBySCQTY has too many arguments specified.'
UPDATED ERROR
System.Runtime.InteropServices.COMException: 'Procedure or function 'pro_SearchInvBySCwithQTY' expects parameter '@Qty', which was not supplied.'
These is my current code:
VB.NET
If rsfind.State = ConnectionState.Open Then
rsfind.Close()
End If
rsfind.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rsfind.CursorType = ADODB.CursorTypeEnum.adOpenStatic
rsfind.LockType = ADODB.LockTypeEnum.adLockOptimistic
Dim cmd As New ADODB.Command
With cmd
.ActiveConnection = [redacted]
.CommandText = "pro_SearchInvBySCwithQTY"
.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
For i = cmd.Parameters.Count - 1 To 0 Step -1
cmd.Parameters.Delete(i)
Next i
.Parameters.Append(.CreateParameter("@SearchTerm", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 50, Trim(ListView1.SelectedItems.Item(0).SubItems(0).Text)))
.Parameters.Append(.CreateParameter("@QTY", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput, ListView1.SelectedItems.Item(0).SubItems(3).Text))
rsfind.Open(.Execute)
End With
SQL Server stored procedure
ALTER PROCEDURE [dbo].[pro_SearchInvBySCwithQTY] @SearchTerm NVARCHAR(MAX), @QTY INT
AS
BEGIN
SELECT StockCode, Description, Supplier, AlternateKey1, AlternateKey2, Classification, QtyOnHand, DateLastStockMove, SafetyStockQty, ReOrderQty, SellingPrice, StockOnHold, StockUom, DefaultBin
FROM vw_InventorySearchBySC
WHERE StockCode = @SearchTerm AND QtyOnHand = @QTY
order by DateLastStockMove DESC;
END;
Upvotes: 0
Views: 65