top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

If I am using data reader then how to deal with return value of stored procedure?

+1 vote
393 views
If I am using data reader then how to deal with return value of stored procedure?
posted Jun 11, 2014 by Basabdatta Mukherjee

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

To deal with such scenario, you can find “ParameterDirection. ReturnValue”. You can use this parameter direction to read the return value of the stored procedure. Following example can make it more clearer.
In case, you have following or similar type of return statement somewhere in your stored procedure.

Return -999

To read this value, following code works,

Dim result As Integer = 0
Dim retValParam As New SqlClient.SqlParameter("@RETURN_VALUE", SqlDbType.Int)

        retValParam.Direction = ParameterDirection.ReturnValue

        dbCommand.Parameters.Add(retValParam)

        database.ExecuteNonQuery(dbCommand)

        result = retValParam.Value ‘ here the result must contain the returned value. In this case, it will be -999
answer Jun 12, 2014 by Aastha Joshi
Similar Questions
+4 votes

Is there any method to Debug a Stored Procedure step by step?

0 votes

I have the hex stream of a packet that a program sent over the network. Now I want to view the data in the packet. I'm pretty sure the data was just a string (or at least contains a string), but when I decode it I just get gibberish.

For example, the packet is sent something like this

import socket

s = socket.socket()
s.connect(hostname,port)
data = "HeresAStringToSend"
s.send(data)
# I'm not worried about receiving yet. 
# I just want to know the anatomy of a sent packet.

Then I use a packet sniffer to look at the packet that was sent; this is just a string of hex. Then I isolate the data part of the packet. Let's say the data part of the hex string is in a variable called hexdata.

If I do,

print hexdata.decode("hex")

all I get is gibberish. Looking at the individual bytes in the hex data, they map to strange or invalid ascii codes (e.g. less than 32 or greater than 127).

I don't really know what the s.send(data) method does to the data before sending it. Any help or insight would be great.

+10 votes

I want to retrieve some data from sql server to my application, and from there export some selected data to Excel!

...