Hi, I am writing my first web app in VB.Net, after being very familiar
with C#.Net. I am trying to store the results of the
SqlDataSource.Select() method. In C#, the select method returns a
DataView, which you can manipulate very easily. But I have not had
success using the same method in VB. I did have success using
Enumerators, but i would like to work with the data in a DataTable.
here is some of my code:
in C#:
DataView dv = (DataView)
sdsDataSource.Select(DataSourceSelectArguments.Empty);
int count = dv.Table.Rows.Count();
..... whatever else
in VB, i got this to work
Dim ie As IEnumerable
ie = sdsDataSource.Select(DataSourceSelectArguments.Empty)
Dim dt As IEnumerator = ie.GetEnumerator()
while dt.MoveNext()
Dim dr As System.Data.DataRowView = dt.Current()
Response.Write(dr(0).ToString())
....whatever else
end while
Is it possible to cast an IEnumberable as a DataView or DataTable? I
really want to be able to count the number of rows, and work with the
data in a DataTable.
Thanks!
mschmidt18@gmail.com - 18 Jun 2007 18:32 GMT
I guess i really just needed to hear my problem out loud! after i
wrote it, i did it the same way as C#............
VB
Dim dv As System.Data.DataView
dv = CType(sdsGetFormNo.Select(DataSourceSelectArguments.Empty),
System.Data.DataView)
Dim myField As String = dv.Table.Rows(0)(0).ToString()
Hope this can help someone else!
Patrice - 18 Jun 2007 18:48 GMT
And similarly you have a for each (two words) statement instead of
enumerating by hand in case you would need that at a later time...
---
Patrice
>I guess i really just needed to hear my problem out loud! after i
> wrote it, i did it the same way as C#............
[quoted text clipped - 7 lines]
>
> Hope this can help someone else!