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 SubCode:@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





Reply With Quote