How to loop through rows of strongly typed dataset table

M

moondaddy

In vb.net 1.1 I could do this:

Dim ds As dsEquip = GetDataset()

Dim dr As dsEquip.tbEquipRow
For Each dr In ds.tbEquip.Rows
'Do something
Next

now in c# 2.0 I'm trying to do the same thing like this:

dsEquip ds = oData.PersonGetRecShort();
foreach (dsEquip.tbEquipRow dr in (dsEquip.tbEquipRow)ds.tbEquip.Rows)
{

}

I get a compile error saying:

Error 1 Cannot convert type 'System.Data.DataRowCollection' to
'ClientDataLayer.dsEquip.tbEquipRow' F:\Data\Sample
Projects\WWF\myFormState\BusinessLayer\Persons_BLL.cs 53 63 BusinessLayer

Using c# 2.0, what's the correct way to loop through all the rows in
ds.tbEquip.Rows?

Thanks.
 
M

moondaddy

Found it. It never fails. I can search forever and not find the answer.
As soon as I post a question, I find it. Found this one in a google search.

My problem is I was trying to loop through:
ds.tbEquip.Rows

but all I need to do is loop through:
ds.tbEquip

like this:
foreach (dsEquip.tbEquipRow dr in ds.tbEquip.Rows)
{
}

Anyone care to tall me if this is the difference between vb and cs, or
ado.net 1.1 and 2.0?
 

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