473,625 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loop through columns of all datarows in a dataset

I have a dataset that I queried from an excel sheet. I want to loop through
the rows, then loop through the columns and write them to a file. But I got
stuck pretty quickly:

So far:

For Each dr As DataRow In Order.Tables(0) .Rows

Next

In this for each I want to start a second for each for the columns. But it
seems that a datarow does not have a columns collection I can loop through?

How can I loop through the colomns in each datarow?
Mar 16 '06 #1
2 28093
Philip,

The datacolumn describe the items from the rows.

For Each dr As DataRow In Order.Tables(0) .Rows
For each it as object in dr.ItemArray
'
next
Next

I hope this helps,

Cor

"Philip Wagenaar" <ph************ *@online.nospam > schreef in bericht
news:95******** *************** ***********@mic rosoft.com...
I have a dataset that I queried from an excel sheet. I want to loop through
the rows, then loop through the columns and write them to a file. But I
got
stuck pretty quickly:

So far:

For Each dr As DataRow In Order.Tables(0) .Rows

Next

In this for each I want to start a second for each for the columns. But it
seems that a datarow does not have a columns collection I can loop
through?

How can I loop through the colomns in each datarow?

Mar 16 '06 #2
"Philip Wagenaar" <ph************ *@online.nospam > schrieb
I have a dataset that I queried from an excel sheet. I want to loop
through the rows, then loop through the columns and write them to a
file. But I got stuck pretty quickly:

So far:

For Each dr As DataRow In Order.Tables(0) .Rows

Next

In this for each I want to start a second for each for the columns.
But it seems that a datarow does not have a columns collection I can
loop through?

How can I loop through the colomns in each datarow?

You mean the column values?

for each value as object in dr.itemarray
- or -

for each col as DataColumn in Order.tables(0) .columns
dim value as object
value = dr(col)
next col
Armin
Mar 16 '06 #3

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

Similar topics

4
136593
by: edpdc | last post by:
VB .NET I would like to know how to loop through each row in a data set and get a value from a colum in the data set. My data set has multiple columns. I know I have to use the datarow class but I'm not sure how to do this. I would like to use a for each loop. Any help would be appreciated.
0
1228
by: juli jul | last post by:
Hello, I want a table with 2 columns in a dataset : my problem is that I have to add the values of the first column and only than the values of the secound (from the adapter) - but when adding the first column it automaticlly puts null or something like that in the secound columns.How can I enforse to start adding values of the secound column also to the beggining of dataset? Thank you !
7
2873
by: Nitromuse | last post by:
What is the proper way to refer to a dataset as the collection in a For Each, Next Statement? I want to loop through a particular column in the dataset, I've tried the following with no sucess. For Each x as integer in Dataset1 .... .... .... Next x
1
1917
by: Dave | last post by:
I am relativly new to visual basic, so this may be a no- brainer. I am attempting to use a computed column in a VB dataset defined as followe: ' 'dcCost ' Me.dcCost.ColumnName = "Cost"
24
1426
by: Klaus Jensen | last post by:
Hi! How do I explore in code, which properties (columns) are in a datatable? I need to run some code for each column. I guess the answer is reflection somehow, but I dont know where to start. If someone could point me to a relevant example, I would be most grateful. :)
0
991
by: Mike | last post by:
Hi! I have an ado.net dataset whose main table has 10 columns. Can I create a DataView based on that dataset that has only 3 columns? I also want to name those columns differently than what they're named in the dataset. Is it possible at all without manual looping? If yes, how please? Framework version 1.1 Many thanks in advance,
3
7394
by: ASPnewb1 | last post by:
I am currently filling a dataTable then adding this table to a dataset, setting the dataset to the Gridview's datasource. If I set the Gridview to generate columns automatically it will fill the grid just fine, but I can't get the automated column (column index 1) to be set to readonly. (Column 0 is actually an automated column of edit buttons) here's my code: DataSet ds = new DataSet(); DataTable dt = new DataTable();...
1
3767
by: sbandalli | last post by:
Hi, I have a Datagridview, and it has a comboxcolumn, and textbox column, I want to bind the columns of the my datagridview to dataset, How to go with it??
0
8182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8688
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6115
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4085
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1496
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.