Easy SQL to XML with LINQ and Visual Basic 2008
page 5 of 8
by Richard Dudley
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 38283/ 142

Checking our progress

So far, we've modeled a data context from a view, and written two lines of code.  Can it really be this easy?  Let's add a couple additional lines of code to see.  We'll loop through our entire collection, and print the name of the product to the console window.  The ReadLine method will wait until we press a key to execute, so this will hold the window open long enough for us to see if anything printed out.

Listing 4

Sub Main()
Dim _db As New ProductsDataContext
Dim _products = From p In _db.vProductModelCatalogDescriptions Select p
For Each _p In _products
Console.WriteLine(_p.Name)
Next
Console.ReadLine()
End Sub

Press F5 to start the project, and a console window should open up with the product names printed out.  Press any key to close the window.  It really was that simple to query the data we need.


View Entire Article

User Comments

Title: SQL or XML   
Name: Sunil
Date: 2012-05-21 2:05:53 AM
Comment:
Dear sir,
i want to create and access the Database using VB 2008.
which one i have to use SQL or XML.
Thank u.
Title: hi   
Name: titi
Date: 2008-08-21 8:48:59 AM
Comment:
very nice article

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-10 5:15:15 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search