Turn a single Colum dataset into an array of strings

Turn a single Colum dataset into an array of strings

Post by Kyle Klau » Wed, 28 May 2003 23:40:20



Basically the Subject says it all. I want to take a DataSet with a single
colum and turn it into an array of strings where each string item in the
array is a copy of what was in each row of the DataSet.  I'm using VB.NET
and ADO.NET to do all of this, if this isn't the right newsgroup, my
apologies, please direct me to it.

I'm new to Array's, so thats probably where my problem lies. I know of a way
to get it done, but not the syntax, or if its a good method but it would go
something like this:

Create the DataSet and fill it with my data (I can do this part)
Create a String Array with the same number of spots as the rows in the
dataset
For i = 0 to the largest index of the array
    add to the array at the spot represented by i, the string conversion of
whats in the dataset at the same spot (or i + 1 if datasets aren't
0-indexed, I don't know)
next i

The above seems like its simple enough, I just don't know the syntax to 1)
create an array of a spacific size, or 2) add items to the array at a given
index. Keep in mind I would like to do this with VB.NET, but if you have an
answer in C# (or anything else .NET) I would appreciate it.

Thank you in advance to any help you can give.

-Kyle

 
 
 

Turn a single Colum dataset into an array of strings

Post by Alvin Brune » Fri, 30 May 2003 02:01:53


To turn a single column dataset into an array of strings do
dataset.tables[0].select()

Quote:> Basically the Subject says it all. I want to take a DataSet with a single
> colum and turn it into an array of strings where each string item in the
> array is a copy of what was in each row of the DataSet.  I'm using VB.NET
> and ADO.NET to do all of this, if this isn't the right newsgroup, my
> apologies, please direct me to it.

> I'm new to Array's, so thats probably where my problem lies. I know of a
way
> to get it done, but not the syntax, or if its a good method but it would
go
> something like this:

> Create the DataSet and fill it with my data (I can do this part)
> Create a String Array with the same number of spots as the rows in the
> dataset
> For i = 0 to the largest index of the array
>     add to the array at the spot represented by i, the string conversion
of
> whats in the dataset at the same spot (or i + 1 if datasets aren't
> 0-indexed, I don't know)
> next i

> The above seems like its simple enough, I just don't know the syntax to 1)
> create an array of a spacific size, or 2) add items to the array at a
given
> index. Keep in mind I would like to do this with VB.NET, but if you have
an
> answer in C# (or anything else .NET) I would appreciate it.

> Thank you in advance to any help you can give.

> -Kyle


 
 
 

1. convert Jscript string array to C# string array datatype

I am writting a C# rich clint application interacts with
JScript in browser. How do I pass a string array from
Jscript to C#?

I tried with this statement in Jscript and passed to C#

var items = new Array("TEST", "TEST2", "TEST3");

and then in C#, I got a "System.__ComObject" datatype
back. How do I use that datatype in C# as a string array?
or is there any otherway I can pass a string array
datatype to C# from Jscript?

Thank you.

Alan

2. Triad & Philip Berresford

3. marshalling string arrays or pointer arrays from COM as out parameters

4. Lemmings II -> HD

5. Error when converting a variant array to a string array.

6. Please help with security.

7. How to convert a String array to a byte array?

8. Excel Menu in IE 5

9. Multiple DataTables From Single SP into Single DataSet?

10. Single dataset for multiple independent tables on a single form?

11. String array with pinvoke fails with empty string elements

12. how to turn strings into variable names

13. turn string into DateTime