I am Facing a problem when having a procedure and want to get error_id as my
VS2008 does not work.
I have a procedure that returns some output and when there is error in given data, it returns error_id (or null is everything is ok) in second sql statement:
declare @p6 int
exec Rec_EdStk_EdZB_Sub1_Sp N'2',N'1207',1,5,5,@p6 output
After lauching that code i get these two windows:
So what I need is to get that second sql result in my
I wrote some code:
Dim dta As New DataTable
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim reader As SqlDataReader
Dim quer As 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 "
con.ConnectionString = "server=TRAIN;database=DB;uid=test;pwd=test"
cmd.Connection = con
cmd.CommandText = quer
reader = cmd.ExecuteReader()
When I try to pull data out from datable I get whatever I want from first result output.
For example if I write
MsgBox(dta.Rows(0)(1)) I get value 1 from second column, first row.
But how can I get value from a declared parameter
@p6 (in this case (null)) which output is given in another sql results table?
If someone will suggests to use dataset, please provide an example, as i can't get error_id value using dataset: