Hi there,
I have a BO with a function to call a stored procedure which works, but I get a wrong return value (-1 instead of 1).
This is the scenario.
The BO has a fill-method to laod data from a view which consists of two tables. It connects items for invoices with customer data. Within this I want to delete items from the item-table and refresh the view.
I have a stored procedure which accepts an input value and return an outputvalue, the number of deleted records, which is allways 1.
USE [GALDATA]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[delete_from_tfliste]
@UID int,
@Anzahl Int Out
AS
BEGIN
SET NOCOUNT ON;
DELETE dbo.TEMPFAKT
FROM dbo.TEMPFAKT
WHERE
uid = @UID
select @Anzahl = @@ROWCOUNT
return @Anzahl
END
I call this sp from the BO as mentioned above:
Public Function deletefromview(ByVal nUID As Integer) As Integer
Dim locommand As New SqlCommand("delete_from_tfliste")
locommand.CommandType = Data.CommandType.StoredProcedure
locommand.Parameters.Add("@uid", Data.SqlDbType.Int).Direction = Data.ParameterDirection.Input
locommand.Parameters("@uid").Value = nUID
locommand.Parameters.Add("@Anzahl", Data.SqlDbType.Int).Direction = Data.ParameterDirection.Output
Return ExecuteNonQuery(locommand)
End Function
And the code to call the function is:
If Me.TfListeBO1.Count = 0 Then
Exit Sub
End If
Dim nRet As Integer = Me.TfListeBO1.deletefromview(Me.TfListeBO1.UID)
TfListeBO1.fillall()
As I said above, it works but I get a return value (nRet) of -1 instead of 1, which is returned if I call it in Management Studio.
What have I done wrong?
Best regards
Thomas