473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Datareader-gird irregular order?

63
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.ExecuteReader(conn, CommandType.StoredProcedure, "getResidents")


While dr.Read
Dim objUser As New Data.Resident
objUser.Name = dr("Name")
objUser.Address = dr("Addr")
objUser.MobNo = dr("Mobile")
' objUser.Telephone = dr("Phone")
objUser.Employed = dr("Employed")
objUser.RecordStatusId = dr("RecordStatusId")
arrList.Add(objUser)
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(displayed) 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
May 9 '07 #1
2 1002
kenobewan
4,871 Expert 4TB
I assume that due to datareaders being forward and once only the order is lost where it is retained in the dataset.
May 9 '07 #2
Paulson
63
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.
May 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Yasutaka Ito | last post by:
Hi, My friend had a little confusion about the working of DataReader after reading an article from MSDN. Following is a message from him... <!-- Message starts --> I was going thru DataReader...
6
by: Ravi | last post by:
Hi, I am not able to understand why a datareader needs a connection to the DB all the time. Here is what I tried. Sqlcommand cmd = ("select * from table1",con) // where con is the connection...
5
by: Jason Huang | last post by:
Hi, Is it possible to bind DataReader to a DataGrid in C# windows form? And how? And can we update data in a DataSet by using the DataReader? Thanks for help. Jason
12
by: Thomas Scheiderich | last post by:
I have 2 dropdowns that are exactly the same and I don't want to re-read for each. Is there a way to do something like below where I read the data, bind to depCity1 and then bind to destCity2. ...
20
by: Mark | last post by:
Hi all, quick question , a DataView is memory resident "view" of data in a data table therefore once populated you can close the connection to the database. Garbage collection can then be used to...
2
by: Andrei Pociu | last post by:
In a typical ASP .NET Web Application (website), I'm currently using a class where I declare some public static objects. For example there's the place where I initialize the SqlConnection. Also...
1
by: Brent | last post by:
I'm having a hard time wrapping my head around how to build a multi-dimensional array of n length out of a DataReader loop. Take this pseudo-code: ======================================= public...
7
by: Varangian | last post by:
Hi all, the question I want to ask if the conversion of a DataReader to a Table looping through the DataReader is better than using the Fill Method of the DataAdapter... I'm asking because...
7
by: Diffident | last post by:
Hello All, I would like to use DataReader based accessing in my Data Access Layer (DAL). What is considered to be a best practice while returning from a DAL method that executes a query and...
3
by: Johnny Jörgensen | last post by:
I've got an error that I simply cannot locate: I've got a form in which I use a datareader object to read information from a db. After the read, I close the reader and I dispose of both the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.