Datareader-gird irregular order?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paulson
    New Member
    • Apr 2007
    • 63

    #1

    Datareader-gird irregular order?

    Hi In my Desktop Application I call a function from UI

    The code is as follows

    _______________ _______________ _______________ _____ _______________ _

    Dim objDataHandler As New DataHandler
    Try
    dgResidentList. DataSource = objDataHandler. getResidents()
    dgResidentList. ReadOnly = True
    dgResidentList. Enabled = False
    Catch ex As Exception

    End Try
    _______________ _______________ _______________ _____ _______________ _

    The db related operation where datreader reads the values [Code] is as follows

    _______________ _______________ _______________ _____ _______________ _

    Public Function getResidents() As ArrayList

    Dim arrList As New ArrayList
    Dim dr As SqlDataReader
    Dim conn As String
    conn = getConn()
    dr = SqlHelper.Execu teReader(conn, CommandType.Sto redProcedure, "getResiden ts")


    While dr.Read
    Dim objUser As New Data.Resident
    objUser.Name = dr("Name")
    objUser.Address = dr("Addr")
    objUser.MobNo = dr("Mobile")
    ' objUser.Telepho ne = dr("Phone")
    objUser.Employe d = dr("Employed")
    objUser.RecordS tatusId = dr("RecordStatu sId")
    arrList.Add(obj User)
    End While

    Return arrList


    End Function
    _______________ _______________ _______________ _____ _______________ _

    The sql query(stored procedre written is )

    [ Select * from DamecResident] ------------>Damec Resident is a table

    I am developing and Desktop(Windows ) Application using VB.Net.
    I am using -------->"sqldatareader "<-------- to retrieve values from the database.
    The values retrieved from the db is passed as an arraylist.
    Everything works fine untill I bind the arraylist with the datagrid.
    All values are coming(displaye d) in grid but the order is ------->Irregular<--------

    Does any one know why this happens.Pls tell me if u know(Please also tell me the reason why it comes like that).

    But if I use DataSet there is no problem. PLs help guys and gals.

    Thanx in advance
    bye Paulson
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    I assume that due to datareaders being forward and once only the order is lost where it is retained in the dataset.

    Comment

    • Paulson
      New Member
      • Apr 2007
      • 63

      #3
      Originally posted by kenobewan
      I assume that due to datareaders being forward and once only the order is lost where it is retained in the dataset.
      Hi kenu

      Thanks for your reply.But I did not get you fully.What is the meaning of

      [------>datareaders being forward and once only the order is lost <------]

      I did not get you,and isn't there any solution for this?Pls reply whatever be the answer.

      Thankyou bye Paulson.

      Comment

      Working...