473,320 Members | 1,991 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,320 software developers and data experts.

using Arraylist to store SQL data - equivalent of GetRows

si
I'm very new to using C# in an ASP.NET application, and am used to
using the ADO GetRows() method to quickly dump data into a
multidimensional array in classic ASP.

I am trying to work through using the ArrayList class in ASP.NET to
perform a similar role, but am having difficulty in understanding and
knowing how to access the data once it has been placed in an
ArrayList.
//Place data from SQL query into ArrayList
ArrayList alRows = new ArrayList();
SqlConnection objConn = new SqlConnection();
objConn.ConnectionString = "conn string here"
objConn.Open();
SqlCommand objCmd = new SqlCommand();
objCmd.Connection = objConn;
objCmd.CommandText = "qry here";
SqlDataReader objRdr = objCmd.ExecuteReader();

while (objRdr.Read())
{
ArrayList alFields = new ArrayList();
for (int i = 0; i < objRdr.FieldCount; i++)
alFields.Add(objRdr[i]);
alRows.Add(alFields);
}
objRdr.Close();
objCmd.Close();

How do I iterate through the ArrayList "alRows" to display each row
and field?
Nov 16 '05 #1
0 6229

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Stuart | last post by:
I have a small class of data values made up of ints and bools totalling 25 bytes. Each of these 25 byte nodes is stored in another class as an ArrayList with a few more ints. Typically there are...
0
by: Rizky Kurniawan | last post by:
Hi geek, Please help.... I've value let say textbox, then i would put that value on datagrid I've option from which I do post to the grid. I store textbox value first to ArrayList and then...
0
by: VeeraLakshmi | last post by:
I am doing a project for internet control using Java,PHP and MySql.All sites should go through the proxy server only.We are giving access rights as allow or deny to the sites.If we type the...
8
by: stainless | last post by:
I am not very experienced with C# and have a question regarding storing and accessing data in an array list. Whilst reading a datarow sorted on 3 fields (thID, dthID and locID - all 3 are type...
4
by: StinkyDuck | last post by:
I'm trying to determine which type of collection to use, DataTable or ArrayList. I understand that an ArrayList can be linked to databound objects if it contains the IList interface. Is there a...
9
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows()...
3
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method...
6
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1)...
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello My pgm1 (User Interface Level) passes an empty ArrayList to pgm2 (Business Logic Level). pgm2 then calls pgm3 (Data Access Level) to populate the ArrayList. Question1: When pgm2 gets...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.