sql server - Show sql procedure error_id output in VisualStudio2008 -


i facing problem when having procedure , want error_id vs2008 not work.
have procedure returns output , when there error in given data, returns error_id (or null ok) in second sql statement:

declare @p6 int  set @p6=null  exec rec_edstk_edzb_sub1_sp n'2',n'1207',1,5,5,@p6 output  select @p6  

after lauching code these 2 windows: enter image description here

so need second sql result in vs2008 project. wrote code:

        dim dta new datatable         dim con new sqlconnection         dim cmd new sqlcommand         dim reader sqldatareader         dim quer string = "declare @p6 int "         quer += " set @p6=null "         quer += " exec rec_edstk_edzb_sub1_sp n'2',n'1207',1,5,5,@p6 output "         quer += " select @p6 "          try             con.connectionstring = "server=train;database=db;uid=test;pwd=test"             con.open()             cmd.connection = con             cmd.commandtext = quer             reader = cmd.executereader()             con.close()         catch             msgbox("connection error")         end try 

when try pull data out datable whatever want first result output.
example if write msgbox(dta.rows(0)(1)) value 1 second column, first row.
how can value declared parameter @p6 (in case (null)) output given in sql results table?
*********edit**********
if suggests use dataset, please provide example, can't error_id value using dataset:
enter image description here

this because using datareader. output parameters available after datareader closed.
microsoft support:

cause
output parameters returned @ end of data stream when using datareader object.

resolution
when using datareader, must close or read end of data before output parameters visible.

this reason prefer work dataset when need output parameters.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -