473,473 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Why can't I enumerate a DataViewRow?

This test is generating a compile error:

private void BuildFTPRec(DataRowView a, DataRowView h)
{
foreach (DataRow r in a)
{
foreach (DataColumn dc in r)
{
Console.WriteLine(r.ToString());
}
}
}

The error is:
C:\Data\projects\TwsFtpOutTest\TwsFtpOutTest\Class 1.cs(59): foreach
statement cannot operate on variables of type 'System.Data.DataRow' because
'System.Data.DataRow' does not contain a definition for 'GetEnumerator', or
it is inaccessible
Nov 16 '05 #1
1 3562

"Bill" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
This test is generating a compile error:

private void BuildFTPRec(DataRowView a, DataRowView h)
{
foreach (DataRow r in a)
{
foreach (DataColumn dc in r)
{
Console.WriteLine(r.ToString());
}
}
}

The error is:
C:\Data\projects\TwsFtpOutTest\TwsFtpOutTest\Class 1.cs(59): foreach
statement cannot operate on variables of type 'System.Data.DataRow' because 'System.Data.DataRow' does not contain a definition for 'GetEnumerator', or it is inaccessible


For exactly the reason it says. A DataViewRow points to a single DataRow,
and a DataRow isn't enumerable either. The DataRow has a Table which has a
Columns collection, though.

Like this:
private void BuildFTPRec(DataView dv)
{
foreach (DataRowView r in dv)
{
foreach (DataColumn dc in r.Row.Table.Columns)
{
Console.Write(r.Row[dc].ToString());
}
}
}

David
Nov 16 '05 #2

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

Similar topics

5
by: Pekka Niiranen | last post by:
Hi, I have Perl code looping thru lines in the file: line: while (<INFILE>) { ... $_ = do something ... if (/#START/) { # Start inner loop
2
by: Johann Blake | last post by:
When adding a new row to a DataView, is it possible to cast the returned DataViewRow to a typed row? Without casting, I am forced to indicate the names of fields as strings when setting their...
1
by: John Chorlton | last post by:
I've been attempting to pass a chunk of data back from a child Windows form using public properties on the form and have been getting some odd errors. I wanted to return a row of data to avoid...
6
by: Gregory Petrosyan | last post by:
Hello! I have a question for the developer of enumerate(). Consider the following code: for x,y in coords(dots): print x, y When I want to iterate over enumerated sequence I expect this to...
21
by: James Stroud | last post by:
I think that it would be handy for enumerate to behave as such: def enumerate(itrbl, start=0, step=1): i = start for it in itrbl: yield (i, it) i += step This allows much more flexibility...
12
by: Danny Colligan | last post by:
In the following code snippet, I attempt to assign 10 to every index in the list a and fail because when I try to assign number to 10, number is a deep copy of the ith index (is this statement...
8
by: eight02645999 | last post by:
hi say i want to enumerate lines of a file eg for n,l in enumerate(open("file")): # print next line ie is there a way to print out the next line from current line using the above?. Or do i...
7
by: Nikhil | last post by:
Hi, I am reading a file with readlines method of the filepointer object returned by the open function. Along with reading the lines, I also need to know which line number of the file is read in...
2
by: cloftis | last post by:
Using VS2003, VB and MSHTML, Using an HTMLSpanElement I want to enumerate the attributes of a SPAN tag. 1 'For testing sake 2 Dim strMarkup as String = "<span attr1='somevalue'...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.