如何从存储过程中取出第二行值

时间:2022-05-10 12:37:39

I have stored procedure like this:

我有这样的存储过程:

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

Return value 0

返回值为0

How I can fetch Transid value in vb.net? I Fetchd first row value like this:

如何在vb.net中获取传递值?我获取第一行的值如下所示:

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

while fetching transid value like this am getting error,,,is there any way to fetch second row value

当像这样获取transid值时,会出现错误,有办法获取第二行值吗

1 个解决方案

#1


0  

(Copied from https://*.com/a/12715687/62072).

从https://*.com/a/12715687/62072(复制)。

See SqlDataReader.NextResult (an SqlDataReader is returned from calling SqlCommand.ExecuteReader):

看到SqlDataReader。NextResult (SqlDataReader从调用SqlCommand.ExecuteReader返回):

Advances the data reader to the next result [set], when reading the results of batch Transact-SQL statements.

当读取批处理事务- sql语句的结果时,将数据读取器推进到下一个结果[set]。

(See this example and this example for usage. YMMV.)

(请参阅这个示例和这个示例以了解用法。YMMV)。

#1


0  

(Copied from https://*.com/a/12715687/62072).

从https://*.com/a/12715687/62072(复制)。

See SqlDataReader.NextResult (an SqlDataReader is returned from calling SqlCommand.ExecuteReader):

看到SqlDataReader。NextResult (SqlDataReader从调用SqlCommand.ExecuteReader返回):

Advances the data reader to the next result [set], when reading the results of batch Transact-SQL statements.

当读取批处理事务- sql语句的结果时,将数据读取器推进到下一个结果[set]。

(See this example and this example for usage. YMMV.)

(请参阅这个示例和这个示例以了解用法。YMMV)。