Home All Groups Group Topic Archive Search About

Read value of all columns from datatable together

Author
5 Jun 2006 12:41 PM
neeraj
Hi
     Could any one suggest me, is there any way to I get the all column
value from data row together?

For exp

Dim dr as datarow
Dim str as string

For each dr in tbl.datarow

'Here I want all column value of current row in one string type
variable with comma separated without using any loop (
like
      Str = all column value of data row

next

Actually I want to convert data table to .csv file without using loop
for columns.
Is it possible?

Thanks

Author
5 Jun 2006 2:12 PM
Cor Ligthert [MVP]
If you don't need columnheaders in your CSV and only uses as delimiter the
"," or ";" than it is not needed.

If you want that information than you have to loop through that collection
as you do for erver colletions. What is strange on that. .

Cor

Show quoteHide quote
"neeraj" <neeraj.***@gmail.com> schreef in bericht
news:1149511261.935967.109160@i39g2000cwa.googlegroups.com...
> Hi
>     Could any one suggest me, is there any way to I get the all column
> value from data row together?
>
> For exp
>
> Dim dr as datarow
> Dim str as string
>
> For each dr in tbl.datarow
>
> 'Here I want all column value of current row in one string type
> variable with comma separated without using any loop (
> like
>      Str = all column value of data row
>
> next
>
> Actually I want to convert data table to .csv file without using loop
> for columns.
> Is it possible?
>
> Thanks
>
Author
5 Jun 2006 5:13 PM
Marina Levit [MVP]
If all your columns are of string type, you can do something like:

str = String.Join(", ", CType(r.ItemArray, String()))

If 'r' is your variable for the datarow.  In this case the separator is a
comma and a space.

Note, if there are other datatypes involved, this won't work.

But really, I don't see an issue with looping - it's not like it is exactly
a lot of code to write. It's a pretty trivial algorithm.


Show quoteHide quote
"neeraj" <neeraj.***@gmail.com> wrote in message
news:1149511261.935967.109160@i39g2000cwa.googlegroups.com...
> Hi
>     Could any one suggest me, is there any way to I get the all column
> value from data row together?
>
> For exp
>
> Dim dr as datarow
> Dim str as string
>
> For each dr in tbl.datarow
>
> 'Here I want all column value of current row in one string type
> variable with comma separated without using any loop (
> like
>      Str = all column value of data row
>
> next
>
> Actually I want to convert data table to .csv file without using loop
> for columns.
> Is it possible?
>
> Thanks
>