I am trying to call a simple stored procedure with that returns an OUTPUT parameter from a VB.NET application, but when i try to display the result, it appears blank. The code is not throwing any exceptions and when i execute the SP in SQL Server Mgmt studio, it returns as I expect. I am probably just overlooking something. Appreciate any suggestions. SP and VB code are below:
SP Code :
create procedure [dbo].[get_number_potential_matches] @deductnRecId int, @numberPotentialMatches int output as
begin
select numberPotentialMatches = count(*)
from potential_match pm
where pm.deductn_rec_id = @deductnRecId;
return
end
VB.Net Procedure:
Sub getPotentialMatchCount(ByVal deductnRecId As Integer)
Try
SqlCmd = New SqlCommand("get_number_potential_matches", SqlConn)
SqlCmd.CommandType = CommandType.StoredProcedure
SqlCmd.Parameters.Add("@deductnRecId", SqlDbType.Int).Value = deductnRecId
SqlCmd.Parameters("@deductnRecId").Direction = ParameterDirection.Input
SqlCmd.Parameters.Add("@numberPotentialMatches", SqlDbType.Int)
SqlCmd.Parameters("@numberPotentialMatches").Direction = ParameterDirection.Output
SqlConn.Open()
SqlCmd.ExecuteNonQuery()
Catch ex As Exception
lbl_pm.Text = ex.Message
Finally
SqlCmd.Dispose()
SqlConn.Close()
End Try
lbl_pm.Text = "deductnRecId: " & deductnRecId.ToString & " has " & SqlCmd.Parameters("@numberPotentialMatches").Value.ToString() & " matches"
End Sub