Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

VB
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
Posted
Updated 28-Jun-12 0:03am
v2

Remove the first read:
VB
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
 
Share this answer
 
Comments
DamithSL 28-Jun-12 6:10am    
beat me to it, my 5!
DINESH K MAURYA 28-Jun-12 6:26am    
many many Thanks .
but what is the reason?
it working fine when record was few.
VB
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


removed If condition with reader.Read
 
Share this answer
 
v2
Comments
Mehdi Gholam 28-Jun-12 6:25am    
5'ed :)
DamithSL 28-Jun-12 6:32am    
thanks Mehdi
DINESH K MAURYA 28-Jun-12 6:52am    
thanks mehdi and Damith

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900