Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 8th, 2008, 07:22 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default [Resolved] Get return value from stored procedure

I am having difficulties getting a result back after calling a sp. Most likely this is due to me not understanding the interaction. Wonder if someone could help?

Here is my VB 2005 code:

Code:
EquentialCommand.Parameters.Add(New Data.SqlClient.SqlParameter("@RetValue", Data.SqlDbType.Char, 50))
EquentialCommand.Parameters("@RetValue").Direction = Data.ParameterDirection.Output
EquentialCommand.CommandType = Data.CommandType.StoredProcedure
EquentialCommand.CommandText = ("sp_Vecellio_JobInquiry1")
EquentialCommand.Connection = EquentialConnection
mySqlDataAdapter.SelectCommand = EquentialCommand
RetValue = EquentialCommand.Parameters("@RetValue").Value.ToString
If RetValue <> Nothing Then
                myError = True
                ASPNET_MsgBox(RetValue)
            Else
                mySqlDataAdapter.Fill(mySqlDataTable)
                EquentialCommand.Parameters.Clear()
                EquentialConnection.Close()
End If
Her is my query snippet:

Code:
CREATE PROCEDURE dbo.sp_Vecellio_JobInquiry1
(
    @JobNumber INT,
    @UserID VARCHAR(10),
    @Text VARCHAR(20) = NULL,
    @DateFrom DATETIME = NULL,
    @DateTo DATETIME = NULL,
        @RetValue CHAR(50) OUTPUT
)

AS

SET NOCOUNT ON

CREATE TABLE    #AuthorityTable
        (
            busunit_from BIGINT,
            busunit_to BIGINT
        )

INSERT    #AuthorityTable
    (
        busunit_from,
        busunit_to
    )

SELECT    msmcuf, msmcut
FROM    OPENQUERY(vgsys400, 'SELECT * FROM vgisec.f0001')
WHERE    msuser = @UserID

IF @@ROWCOUNT = 0
    BEGIN
    SET @RetValue = 'You are not authorized to any selections.'
    RETURN
    END


If I do not find any records from the 'openquery' then I would like to return message to my program
Reply With Quote
  #2 (permalink)  
Old August 8th, 2008, 11:05 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Finally solved my vb code this way:

Code:
EquentialCommand.Parameters.Add(New Data.SqlClient.SqlParameter("@RetValue", Data.SqlDbType.Char, 50)).Value = Nothing
            EquentialCommand.Parameters("@RetValue").Direction = Data.ParameterDirection.Output
            EquentialCommand.CommandType = Data.CommandType.StoredProcedure
            EquentialCommand.CommandText = ("sp_Vecellio_JobInquiry1")
            EquentialCommand.Connection = EquentialConnection
            mySqlDataAdapter.SelectCommand = EquentialCommand
            mySqlDataAdapter.Fill(mySqlDataTable)
            Dim ReturnValue As String = EquentialCommand.Parameters("@RetValue").Value.ToString
            If ReturnValue <> Nothing Then
                myError = True
                ASPNET_MsgBox(ReturnValue)
            Else
                EquentialCommand.Parameters.Clear()
                EquentialConnection.Close()
            End If
        Catch ex As Exception
            ErrorString = ex.ToString
            ASPNET_MsgBox("An error has occurred connection to server and loading table: " + vbCrLf + ErrorString)
        End Try


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure return value is NULL kshort ASP.NET 2.0 Basics 16 March 14th, 2017 12:45 PM
Stored Procedure return value dmiles C# 3 December 6th, 2007 05:20 AM
how can i return a recrdset in a stored procedure? arathy ASP.NET 1.0 and 1.1 Basics 0 December 12th, 2006 04:24 AM
Can i return a recordset in a Stored procedure chiefouko VB Databases Basics 6 December 12th, 2006 03:34 AM
how i use the Stored Procedure return value and ho yoord ADO.NET 5 June 28th, 2004 08:39 AM



All times are GMT -4. The time now is 03:35 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.