Read value of all columns from datatable together

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
 
C

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
 
M

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top