Database Code
  Home arrow Database Code arrow Using the AccessDataSource Control in VS 2...
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 CODE

Using the AccessDataSource Control in VS 2005
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2006-07-17

    Table of Contents:
  • Using the AccessDataSource Control in VS 2005
  • Querying the database
  • Binding the query result to a GridView
  • Binding data to a drop-down list control

  • 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

    Ajax Application Generator Generate database 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!

    Using the AccessDataSource Control in VS 2005
    (Page 1 of 4 )

    Microsoft Access Database is file based. Accessing it with an OleDB provider, or an ODBC provider, is the norm. Since the whole database is in one file, a file reference should be all that is necessary to connect to it, and Microsoft has that for you in VS 2005 in the form of the AccessDataSource Control.

    However, if the database is protected by a username and password, this is not the method to use, because the AccessDataSource Control can only connect to databases without password protection. The upside in using this control is that it only needs to know where the *.mdb file is located, as we shall see in the course of this tutorial.

    AccessDataSource, as the next picture shows, inherits directly from System.Web.UI.WebControls.SQLDataSource, its base class. This code-based tutorial shows how you may use this control to access data on a Microsoft Access Database and then bind the results to two controls, a GridView and a DropDownList.

    Creating a web page with the AccessDataSource Control

    Create a new web site project named AccessDS as shown in the picture, and onto the default.aspx page in design view, add an AccessDataSource control. This adds a control named AccessDataSource1 as shown. If you click on the arrow at the top right on this control, you get a drop-down showing the tasks that need to be performed. Now click on the hyperlink Configure Data Source....

     

    This should open up the window shown in the next picture, where you will carry out the configuration of the datasource. Either you can enter a relative path to a database *.mdb file, or browse to one on your hard drive.

     

    However, as seen in the next picture, it does not show any source, nor will it let you browse the hard drive.

    Here you may have to copy the database file you want to your application folder in the application directory (C:InetpubwwwrootAccessDS App_Data). This will make the nwind.mdb file (in this tutorial) part of the application. Copying to the App_Data directory provides an additional layer of protection, as this directory will not be served.

    When you again try to configure the data source you will come to the next screen, where you can now highlight the nwind.mdb file in the right pane and click on the OK button.

     

    Now the configure Data Source window shows the relative path to the database, ~/App_Data/nwind.mdb as shown. Click on the Next button.

     

    More Database Code Articles
    More By Jayaram Krishnaswamy


       · It's not only athletes take steroids, even programs can. AccessDataSource control...
     

    DATABASE CODE ARTICLES

    - Deployment of the MobiLink Synchronization M...
    - MobiLink Synchronization Wizard in SQL Anywh...
    - Finding Matching Records in Data Access Pages
    - Using the AccessDataSource Control in VS 2005
    - A Closer Look at ADO.NET: The Command Object
    - A Closer Look at ADO.NET: The Connection Obj...
    - Using ADO to Communicate with the Database, ...
    - Code Snippets: Counting Records
    - Constraints In Microsoft SQL Server 2000
    - Multilingual entries into a DB and to be dis...
    - Getting A List of Tables From SQL Server
    - SQL Server Database Creator - .NET Version
    - ADO Recordset Paging
    - Two combos, one textbox example
    - Discussion & Listserv Module by Mike Eck...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




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