I am at a loss here, I don't understand why the procedure is not getting this parameter...
Procedure (procInfoColor
):
ALTER PROCEDURE [dbo].[procInfoColor]
(@ID int)
AS
BEGIN
SELECT Id, Code, [Description], IsActive FROM tblColor WHERE Id = @ID
END
VB.Net code:
Public Function infoColor(ID As Integer) As List(Of Colors) Implements iMaintenance.infoColor
Dim p = New DynamicParameters()
p.Add("@ID", ID, DbType.Int32)
Try
Return DbConn.Query(Of Colors)("procInfoColor", p, Nothing, 60, CommandType.StoredProcedure).ToList()
Catch ex As Exception
End Try
End Function
SQL Trace command (Text Data) - Command is generated by the VB.NET procedure call:
exec sp_executesql N'procInfoColor',N'@ID int',@ID=9
Error:
Msg 201, Level 16, State 4, Procedure procInfoColor, Line 2 Procedure or function 'procInfoColor' expects parameter '@ID', which was not supplied.
I can run this just fine when executing the procedure through a right click, but when I call the procedure from my VB.Net application I am getting this error message stating @ID
is not being supplied. I checked the SQL trace and it sure looks like it is being supplied to me?
Any help at all would be appreciated.
Possible duplicate of: Execute stored procedure w/parameters in Dapper
Try using the named parameter name for the Command Type when making the Dapper call:
Public Function infoColor(ID As Integer) As List(Of Colors)
Implements iMaintenance.infoColor
Dim p = New DynamicParameters()
p.Add("@ID", ID, DbType.Int32)
Try
Return DbConn.Query(Of Colors)("procInfoColor",
p,
Nothing,
60,
commandType:=CommandType.StoredProcedure ).ToList()
Catch ex As Exception
End Try
End Function