Thursday, February 12, 2009

Result Sets with Output Parameters

I recently wrote a stored procedure that optionally returns a result set AND uses output parameters: something I'd never done before. Logically I thought the best approach would be to grab the values from the output parameters first, then try to iterate over the optional result set. Everything seemed peachy, except all my output parameter values were dbnull. What gives?

Luckily my first result for "output parameter reader" provided me with the answer:
http://www.velocityreviews.com/forums/t94779-reading-both-result-set-and-output-parameter-of-sp-in-net-framework.html

Aparently the values for the output parameters are passed to the client only after all of the result sets have been processed and the reader has been closed. Works like a charm now.

Thank you Bruce Barker!

No comments:

Post a Comment