Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

VB SqlDataSource.Select

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mschmidt18@gmail.com - 18 Jun 2007 18:17 GMT
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!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.