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

Getting Started

Open Visual Basic 2008 Express, and create a new project.  Choose a Console Application, and name it whatever you want—I've named mine ProductstoXml.

Figure 1

Our project will open with Module1.vb.  In order to retrieve data from our database, we need to add a LINQ to SQL class, which will provide us with the methods for easy data access.  Right-click on the project, choose Add >> New Item.  Select LINQ to SQL Classes, name it Products.dbml, and click OK.  We'll now have a split screen with the Object Relational Designer in the left pane and a method creator on the right.

Figure 2

Click the Database Explorer link in the Object Relational Designer.  The Database Explorer toolbar should open.  Add a Data Connection. Choose Microsoft SQL Server Database File and click OK.

Figure 3


On the next screen, we need to Browse to the database, which for SQL Server Express 2005 is installed by default at C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data.  Choose Adventureworks_Data.mdf, and click Open, then OK.

Figure 4

The connection to Adventureworks_Data.mdf will now be listed in the Database Explorer toolbar.  Expand the database, and then the Views.  To finish creating the class, locate the vProductModelCatalogDescription view and drag and drop it onto the Object Relational Designer, as shown. If you're prompted to copy the data file to your project, click No.  Save this file, and switch back to Module1.vb.

Figure 5

View Entire Article

User Comments

Title: SQL or XML   
Name: Sunil
Date: 2012-05-21 2:05:53 AM
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
very nice article

Product Spotlight
Product Spotlight 

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

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