RETRIVE MESSAGE FROM SQL PROCEDURE

L

Lal

Hello,
I created a procedure in sql with 3 parameters last parameter is output
parameter, now I want to get the parameter value to my vb.net application.
how can i do that
please help



--



Regards


K R Lal
 
A

Adam Goossens

Hi Lal,

Create your output paramater, do not provide a value for it, set it's
direction to ParameterDirection.Output and exuecte your command.

Once the command has executed the parameter's "Value" property will
contain the output value.

---
Dim cmd as SqlCommand
Dim paramOut as SqlParameter

' make sure you change the dbtype accordingly.
paramOut = New SqlParameter("@OutputVar", SqlDbType.Int)
paramOut.Direction = ParameterDirection.Output

' build cmd...
cmd.ExecuteNonQuery() ' if the proc doesn't return any records.

' paramOut.Value will now contain the value passed from your sproc
---

If you want to get a return value, repeat the process except change the
ParameterDirection to ParameterDirection.ReturnValue.

Regards,
-Adam.
 
A

Adam Goossens

Oh, of course: don't forget to add your parameter to your command :)

I forgot to include that.
Regards,
-Adam.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top