Friday, March 16, 2012

Looping through datarow

Hi,

I am passing a datarow to a function and need to iterate through this
datarow and parse it. The number of columns is unknown so I need to do
something like this:

Public Sub ConvertByTabsDataRow(ByVal drIn As DataRow)

For i = 0 To drIn.ItemArray.Count
If drIn.IsNull Then
strLine = strLine & "N/A" & Chr(9)
Else
strLine = strLine & drIn.ItemArray(i).toString() & Chr(9)
End If
Next

End Sub

Count is not a member of ItemArray so I can not use it, how do I iterate
through this datarow?

Thank youDim cnt As Integer

cnt = drIn.Table.Columns.Count

For i = 0 To cnt-1
If (drIn(i).IsNull Then
...
...
Next

HTH

"AMD Desktop" <makblair@.yahoo.com> wrote in message
news:CMCdnWAd-_lDixTcRVn-jg@.magma.ca...
Hi,

I am passing a datarow to a function and need to iterate through this
datarow and parse it. The number of columns is unknown so I need to do
something like this:

Public Sub ConvertByTabsDataRow(ByVal drIn As DataRow)

For i = 0 To drIn.ItemArray.Count
If drIn.IsNull Then
strLine = strLine & "N/A" & Chr(9)
Else
strLine = strLine & drIn.ItemArray(i).toString() & Chr(9)
End If
Next

End Sub

Count is not a member of ItemArray so I can not use it, how do I iterate
through this datarow?

Thank you
Thanks a lot

"Shiva" <shiva_sm@.online.excite.com> wrote in message
news:OYzxW0cwEHA.908@.TK2MSFTNGP11.phx.gbl...
> Dim cnt As Integer
> cnt = drIn.Table.Columns.Count
> For i = 0 To cnt-1
> If (drIn(i).IsNull Then
> ...
> ...
> Next
> HTH
> "AMD Desktop" <makblair@.yahoo.com> wrote in message
> news:CMCdnWAd-_lDixTcRVn-jg@.magma.ca...
> Hi,
> I am passing a datarow to a function and need to iterate through this
> datarow and parse it. The number of columns is unknown so I need to do
> something like this:
> Public Sub ConvertByTabsDataRow(ByVal drIn As DataRow)
> For i = 0 To drIn.ItemArray.Count
> If drIn.IsNull Then
> strLine = strLine & "N/A" & Chr(9)
> Else
> strLine = strLine & drIn.ItemArray(i).toString() & Chr(9)
> End If
> Next
> End Sub
> Count is not a member of ItemArray so I can not use it, how do I iterate
> through this datarow?
> Thank you

0 comments:

Post a Comment