473,324 Members | 2,456 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,324 software developers and data experts.

results of a sql query to array

I am using asp.net 2.0.
I want to get the results of a sql query into an array at run-time.
Number of records returned varies each time.....so I want to declare
the dimensions of array runtime based on my record count and assign the
values from recordset to the elements of array.

any help?

Jun 8 '06 #1
6 3644
"loga123" <vd**********@covansys.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
I am using asp.net 2.0.
I want to get the results of a sql query into an array at run-time.
Number of records returned varies each time.....so I want to declare
the dimensions of array runtime based on my record count and assign the
values from recordset to the elements of array.

any help?


A little difficult without the answers to two questions:

1) Does it *have* to be an array? The System.Collections and
System.Collections.Generic namespaces have got such rich functionality these
days that the old array object is pretty much redundant.

2) What do you intend to do with the array (or whatever) once you've got the
results of your SQL query into it?
Jun 8 '06 #2
Use the SqlCommand object's ExecuteReader and fill an arraylist of items.
Either return the arraylist or convert the types you store in it as an array
like this:

return (string[])myList.ToArray(typeof(string));

--
-Demetri
"loga123" wrote:
I am using asp.net 2.0.
I want to get the results of a sql query into an array at run-time.
Number of records returned varies each time.....so I want to declare
the dimensions of array runtime based on my record count and assign the
values from recordset to the elements of array.

any help?

Jun 8 '06 #3
Hi... I am new to .net and do not have much knowledge about the
controls available in .net.

actually my requirement is
1) I have a SQL that would return rows like
colA colB colC colD
1 R1 1 S11
1 R1 2 S12
1 R1 3 S13
2 R2 1 S21
2 R2 2 S22
3 R3 1 S31
3 R3 2 S32
3 R3 3 S33
where colA and colC are integers and colB and colD are string type.

2) I want to build a table (like an HTML table) DYNAMICALLY as
following
1. R1
(radio button) S11
(radio button) S12
(radio button) S13
2. R2
(radio button) S21
(radio button) S22
3. R3
(radio button) S31
(radio button) S32
(radio button) S33

Number of options under each group 1, 2, 3 will differ.
Any ideas/suggestions?


Mark Rae wrote:
"loga123" <vd**********@covansys.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
I am using asp.net 2.0.
I want to get the results of a sql query into an array at run-time.
Number of records returned varies each time.....so I want to declare
the dimensions of array runtime based on my record count and assign the
values from recordset to the elements of array.

any help?


A little difficult without the answers to two questions:

1) Does it *have* to be an array? The System.Collections and
System.Collections.Generic namespaces have got such rich functionality these
days that the old array object is pretty much redundant.

2) What do you intend to do with the array (or whatever) once you've got the
results of your SQL query into it?


Jun 8 '06 #4
"loga123" <vd**********@covansys.com> wrote in message
news:11**********************@j55g2000cwa.googlegr oups.com...
Hi... I am new to .net and do not have much knowledge about the
controls available in .net.


No problem with that - no-one was born knowing this stuff.

HOWEVER, do yourself a *huge* favour, step back a bit, and buy yourself a
beginner's guide to ASP.NET which contains plenty of examples of how ASP.NET
and ADO.NET interact. There simply is no benefit whatsoever in trying to
figure it out for yourself...

E.g. you have no need at all to use an array to meet your requirements
here - simply return the data from your database into a DataSet object and
bind it to a GridView control. If you don't know what I mean by that, read
the relevant chapter(s) in the beginner's guide to ASP.NET which you've just
bought...
Jun 8 '06 #5
If I use "gridview", how can I display radiobuttons for each group?
Mark Rae wrote:
"loga123" <vd**********@covansys.com> wrote in message
news:11**********************@j55g2000cwa.googlegr oups.com...
Hi... I am new to .net and do not have much knowledge about the
controls available in .net.


No problem with that - no-one was born knowing this stuff.

HOWEVER, do yourself a *huge* favour, step back a bit, and buy yourself a
beginner's guide to ASP.NET which contains plenty of examples of how ASP.NET
and ADO.NET interact. There simply is no benefit whatsoever in trying to
figure it out for yourself...

E.g. you have no need at all to use an array to meet your requirements
here - simply return the data from your database into a DataSet object and
bind it to a GridView control. If you don't know what I mean by that, read
the relevant chapter(s) in the beginner's guide to ASP.NET which you've just
bought...


Jun 8 '06 #6
"Demetri" <De*****@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
Use the SqlCommand object's ExecuteReader and fill an arraylist of items.
Either return the arraylist or convert the types you store in it as an
array
like this:

return (string[])myList.ToArray(typeof(string));


Which means you lose all of the datatype information...

The OP doesn't need to use an array - all he wants to do is display the
results of a database query on a web page...
Jun 9 '06 #7

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

Similar topics

9
by: Börni | last post by:
Hi, I have an sql query like this: SELECT column FROM table WHERE column1="3" AND column2="1" This query works perfectly if i run it in the command line, to be exactly it return two results. But...
6
by: Curt Bousquet | last post by:
Hi; I'm brand new to PHP (just starting today to convert tons of ColdFusion/Access code to PHP/MySQL). There is a function in Coldfusion that I can't find an equivalent to in PHP. Here is what...
7
by: Karin Jensen | last post by:
Hi I am running a PHP program that connects to an Access 2000 database via ODBC: $results = odbc_exec($connection_id, $sql_select); Is it possible to sort the contents of $results? I wish to...
3
by: Eli Criffield | last post by:
I'm getting odd results from my fuction that takes variable aguments. What i want to do is take a printf like format and pass that to mysql_query then i do some processing of the results and...
1
by: SC | last post by:
I'm developing a site that may eventually have a very large database of users (hopefully, but who knows). It will be a community website where users can search each other (think Friendster,...
6
by: JackM | last post by:
I have a multiple select input in a form that's being populated by a row from my database as such: <input type=\"checkbox\" name=\"subm\" value=\"$row\"> That part is working fine as I can check...
2
by: Daniel Di Vita | last post by:
I have created an ASP.NET page that allows the user to page through a result set. I need to expand on this. On that same page I a filed where the user can type in a search string. When they click...
10
by: Lloyd Harold | last post by:
I'm very new to PHP and attempting to put together a simple script for retrieving MySQL data of personal records. The MySQL table I'm using consists of: 0: id 1: name 2: location (an integer...
21
by: bruno_guedesav | last post by:
I've made a function to fetch all results as an array of result- arrays. Getting the result arrays is easy, via mysql_fetch_array, and function itself is quite simple, as follows: function...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
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....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.