Read value of all columns from datatable together

  • Thread starter Thread starter neeraj
  • Start date Start date
N

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
 
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
 
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.
 
Back
Top