我有这样的存储过程:
ALTER procedure [dbo].[carcallvalidation]
@carid nvarchar(100)=null
as
begin
select t.TBarcode, t.Paid,t.Status,t.DelDate from Transaction_tbl t where TBarcode=@carid
declare @transid integer=null
select @transid= t1.transactID from Transaction_tbl t1 where TBarcode=@carid
select count(k.transactid) transid from KHanger_tbl k where k.transactid=@transid
end
while executing stored procedure i am getting out put like this:
Tbarcode paid status
1111 0 2
Transid
2
返回值 0
如何在vb.net中获取Transid值? 我像这样获取第一行值:
Dim cmdcarvalidation As New SqlCommand("carcallvalidation", con.connect)
cmdcarvalidation.CommandType = CommandType.StoredProcedure
cmdcarvalidation.Parameters.Add("@carid", SqlDbType.VarChar, 50, ParameterDirection.Input).Value = txtTicket.Text
dr = cmdcarvalidation.ExecuteReader
While dr.Read
tbarcode=dr("Tbarcode")
payd= dr("paid")
status= dr("status")
end while
虽然像这样获取transid值得到错误,,,有没有办法获取第二行值
答案 0 :(得分:0)
(从https://stackoverflow.com/a/12715687/62072复制)。
请参阅SqlDataReader.NextResult(从调用SqlCommand.ExecuteReader返回SqlDataReader):
在读取批处理Transact-SQL语句的结果时,将数据读取器推进到下一个结果[set]。
(有关用法,请参阅this example和this example。YMMV。)