Database
  Home arrow Database arrow Page 3 - Creating a Database Project in VS 2005
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Creating a Database Project in VS 2005
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2006-07-10

    Table of Contents:
  • Creating a Database Project in VS 2005
  • Creating a new reference database
  • Creating a new query
  • The Query Editor

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Creating a Database Project in VS 2005 - Creating a new query
    (Page 3 of 4 )

    Highlight the Queries node and right click to reveal the drop-down. From the drop down choose Add New Item... . You may also add an existing script, add a query, and so on. For now, we will be creating a query for the referenced database.

    This opens up the templates window, Add New Item, with Database query in the Visual Studio installed templates collection. The default is Query1.dtq; we can change it to something different, details.dtq for example, and click on the button Add.

    Several things happen immediately. Your Project explorer has the details.dtq added to the Queries folder as shown.

    The Query Editor window with four panes, all empty, will be open.

    The Add Table window will be in view with all the tables available from the referenced database, as shown in the next picture. In the Add Table dialog you can hold down either the Shift Key or the Ctrl key and choose multiple tables to be sent to the design pane. Here three tables have been highlighted; they will be used in the design of the query.

    When you click on the Add button in the above window, the selected tables will appear in the design pane of the editor as shown, and a minimal (but incomplete) SQL statement will be generated, showing the joins made based on existing relationships. At this point no columns have been included in the query (right now it is not a query, but a template). You may now close the Add Table window.

    SELECT     
    FROM   (([Order Details] INNER JOIN
    Orders ON [Order Details].OrderID = Orders.OrderID) INNER JOIN
    Products ON [Order Details].ProductID = Products.ProductID)
    

     

    The many-to-many relationship between Orders and Products are related to each other through the Order-Details table, which has a one-to-many relationship with both tables. Let's now pick up a few columns to be added to the query: OrderID, OrderDate, UnitPrice, Quantity, and ProductName from the three tables. We do this by placing a check mark in the check boxes by the side of the column names in each of these tables as shown. Automatically the Criteria pane changes, and the SQL statement takes in all those columns that were added with proper table reference as shown.

    More Database Articles
    More By Jayaram Krishnaswamy


       · VS Studio based database projects provide scripted templates for all occasions from...
     

    DATABASE ARTICLES

    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client
    - ADO`s Stream Object
    - Opening a Record Object Referencing an Open ...
    - Introducing Jasper (SQL Anywhere 10 Beta)
    - Creating a Database Project in VS 2005
    - Manipulating ADO Recordsets




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway