SQL Server在asp.net中返回的reader.read计数小于1的值 [英] reader.read count less than 1 value return by the sql server in asp.net
本文介绍了SQL Server在asp.net中返回的reader.read计数小于1的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我已经从sql db中读取了一些记录,其中有20000多个记录.
我的问题是执行代码时,它从数据库返回少于1条记录
hi all,
i have read some record form the sql db in which more than 20000 records.
my problem is when execute the code it return less than 1 record form the database
reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString_SimphonI, Data.CommandType.StoredProcedure, "dbo.pd_vs_Ins_Bookings_SELECT", sqlParam)
If reader.Read Then
While reader.Read
Dim obj As New CIns_Booking
If Not IsDBNull(reader("BookingID")) Then obj.BookingID = reader("BookingID")
If Not IsDBNull(reader("Trip")) Then obj.Trip = reader("Trip")
If Not IsDBNull(reader("Source")) Then obj.Source = reader("Source")
objList.Add(obj)
End While
End If
Return objList
但是当我通过探查器看到它时,它会按我的意愿重新整理所有行
解决方法.
感谢
but when i see by the profiler it retorn all rows as i want
how to solve it.
thanks
推荐答案
删除第一读:
Remove the first read:
reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString_SimphonI, Data.CommandType.StoredProcedure, "dbo.pd_vs_Ins_Bookings_SELECT", sqlParam)
'If reader.Read Then ' removed
While reader.Read
Dim obj As New CIns_Booking
If Not IsDBNull(reader("BookingID")) Then obj.BookingID = reader("BookingID")
If Not IsDBNull(reader("Trip")) Then obj.Trip = reader("Trip")
If Not IsDBNull(reader("Source")) Then obj.Source = reader("Source")
objList.Add(obj)
End While
'End If
Return objList
reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString_SimphonI, Data.CommandType.StoredProcedure, "dbo.pd_vs_Ins_Bookings_SELECT", sqlParam)
While reader.Read
Dim obj As New CIns_Booking
If Not IsDBNull(reader("BookingID")) Then obj.BookingID = reader("BookingID")
If Not IsDBNull(reader("Trip")) Then obj.Trip = reader("Trip")
If Not IsDBNull(reader("Source")) Then obj.Source = reader("Source")
objList.Add(obj)
End While
Return objList
使用reader.Read
removed If
condition with reader.Read
这篇关于SQL Server在asp.net中返回的reader.read计数小于1的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文