By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,854 Members | 856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,854 IT Pros & Developers. It's quick & easy.

Retrieve Output from a stored Procedure

P: n/a
Hi all,

Need some help again. I am trying to retrieve an output from a Stored
Procedure...not having much luck. If anyone could steer me in the
right direction, it would be appreciated. I'm using SQL 2000 and
VB.Net

the Stored Proc is working fine. The following is just a test to
return it to the program

Dim dbConn As New SqlConnection(LCDBConnect.ConnectionString)
Dim dbCmd As New SqlCommand
Dim da As New SqlDataAdapter(dbCmd)

dbCmd.CommandType = CommandType.StoredProcedure
dbCmd.Connection = dbConn
dbCmd.CommandText = "spRenTempTable"
dbCmd.Parameters.Add("@MyTable", SqlDbType.VarChar)

dbCmd.Parameters("@MyTable").Direction =
ParameterDirection.Output
Try
dbConn.Open()
dbCmd.ExecuteNonQuery()
MessageBox.Show("Return Value : " &
dbCmd.Parameters("@MyTable").Value)
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
dbConn.Close()
End Try
thanks for your help
Dave McKie
11/1/2004
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Check out the at Retrieving the Gazoutas: Understanding SQL Server Return
Codes and Output Parameters
http://www.betav.com/msdn_magazine.htm

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Dave McKie" <da*********@yahoo.com> wrote in message
news:b6*************************@posting.google.co m...
Hi all,

Need some help again. I am trying to retrieve an output from a Stored
Procedure...not having much luck. If anyone could steer me in the
right direction, it would be appreciated. I'm using SQL 2000 and
VB.Net

the Stored Proc is working fine. The following is just a test to
return it to the program

Dim dbConn As New SqlConnection(LCDBConnect.ConnectionString)
Dim dbCmd As New SqlCommand
Dim da As New SqlDataAdapter(dbCmd)

dbCmd.CommandType = CommandType.StoredProcedure
dbCmd.Connection = dbConn
dbCmd.CommandText = "spRenTempTable"
dbCmd.Parameters.Add("@MyTable", SqlDbType.VarChar)

dbCmd.Parameters("@MyTable").Direction =
ParameterDirection.Output
Try
dbConn.Open()
dbCmd.ExecuteNonQuery()
MessageBox.Show("Return Value : " &
dbCmd.Parameters("@MyTable").Value)
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
dbConn.Close()
End Try
thanks for your help
Dave McKie
11/1/2004

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.