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

How to get the output parameter from Store Procedure ?

P: n/a
I try to set an output parameter to get the result from store procedure,
However,Do I still need to loop the reader to get result ?? Thanks a lot

cmdKey.Parameters("@result").Direction = ParameterDirection.Output

Dim drCntrId As SqlDataReader =
cmdKey.ExecuteReader(CommandBehavior.SingleRow)
While drCntrId.Read
strKey = drCntrId.Item("result")
End While

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Output params are not available until the data reader is closed. So, close
the drCntrlId first and then access the output value as
cmdKey.Parameters("@result").Value

You can use SqlCommand.ExecuteNonQuery() instead of ExecuteReader unless you
return rows from the stored proc.

HTH

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:e9**************@TK2MSFTNGP15.phx.gbl...
I try to set an output parameter to get the result from store procedure,
However,Do I still need to loop the reader to get result ?? Thanks a lot

cmdKey.Parameters("@result").Direction = ParameterDirection.Output

Dim drCntrId As SqlDataReader =
cmdKey.ExecuteReader(CommandBehavior.SingleRow)
While drCntrId.Read
strKey = drCntrId.Item("result")
End While


Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.