[RESOLVED] parameter value does not show
Hi this Procedure works fine and so does the stored procedure, at least it compiles successfully , but still the balance is Null and does not display in the txtLABookBalance.Text.
can anyone pls spot the reason???
Code:
Private Sub Get_LABook_Balance()
Dim queryLABookBalance As String = "Report_ONE_LABKBalance"
Dim cmd As New SqlClient.SqlCommand(queryLABookBalance, MyConn)
Try
If cboLABook.SelectedIndex = -1 Then
MessageBox.Show("No L/A Book have been posted for selected L/A")
Else
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@bookFID", cboLABook.SelectedValue)
cmd.Parameters.AddWithValue("@LANo", cboLASuppReport.SelectedValue)
cmd.Parameters.Add("@balance", SqlDbType.Int)
cmd.Parameters("@balance").Direction = ParameterDirection.Output
cmd.Parameters.Add("@ReturnText", SqlDbType.NVarChar, (80))
cmd.Parameters("@ReturnText").Direction = ParameterDirection.Output
MyConn.Open()
If Not CStr(cmd.Parameters("@ReturnText").Value) = String.Empty Then
'LA has no book orders
MessageBox.Show(CStr(cmd.Parameters("@ReturnText").Value).ToString)
Else
txtLABookBalance.Text= (CStr(cmd.Parameters("@balance").Value))
End If 'displaying message if LA has no orders yet
cmd.Parameters.Clear()
MyConn.Close()
End If
Catch ex As Exception
MsgBox(ex.Message)
MyConn.Close()
End Try
End Sub
Code:
@balance int OUTPUT,
@ReturnText nvarchar(80) OUTPUT,
@LANo nvarchar(15),
@bookFID int
AS
BEGIN
DECLARE @count INT
DECLARE @intErrorCode int
SET @count = (SELECT balance from tb_LAbook where (LANo=@LANo AND bookFID=@bookFID))
IF @count > 0
BEGIN
SELECT @balance=balance from tb_LAbook WHERE (LANo=@LANo AND bookFID=@bookFID)
END
ELSE
BEGIN
SET @ReturnText='@LANo ' + (CONVERT(NVARCHAR(15),@LANo))+ 'has no Orders for the selected Book. '
RETURN
END
END
Re: parameter value does not show
you simply missed
Code:
cmd.ExecuteNonQuery()
statement
after MyConn.Open()
:D
Re: parameter value does not show
Hi Rit,
:D WAW . Thanks. Good to see you back. :wave:
Re: parameter value does not show
Quote:
Originally Posted by angelica
Hi Rit,
:D WAW . Thanks. Good to see you back. :wave:
seems problem is solved :p
nowaday too much work at my end :cool: