Hello friends, I want to use the OUTPUT key word in stored procedure to return value
to a front end control and is not working. Below are the codes.
STORED PROCEDURE Code
CREATE procedure prcSumSales
(
@SubTotal Money OUTPUT
)
As
Declare @salDate Datetime
BEGIN
Set @SubTotal = (Select Sum(SubTotal) From dbo.DAILY_SALES
Where SalesDate = @salDate)
select @SubTotal
END
VB Codes
Dim prmt(1) As OleDbParameter
Try
With cmd
con.ConnectionString = renConString
con.Open()
.Connection = net_55
.CommandText = "prcSumSales"
.CommandType = CommandType.StoredProcedure
prmt(0) = New OleDb.OleDbParameter("SalesDate", OleDb.OleDbType.VarChar, Integer.MaxValue)
prmt(1) = New OleDb.OleDbParameter("SubTotal", OleDb.OleDbType.Double, Integer.MaxValue)
prmt(0).Direction = ParameterDirection.Input
prmt(1).Direction = ParameterDirection.Output
.Parameters.AddWithValue("@salDate", txtEnterDate.Text.Trim)
.Parameters.AddWithValue("@SubTotal", 0)
Dim result As Double
.ExecuteNonQuery()
lblTotalSales.Visible = True
result = cmd.Parameters("@SubTotal").Value
lblTotalSales.Text = result
End With
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
End Try
Please this is the error message I get
Procedure or function prcSumSales has too many arguments specified.
Thanks.