Database Code
  Home arrow Database Code arrow Page 4 - Using the AccessDataSource Control in VS 2...
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 
Actuate Whitepapers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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
     
     
    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 - Binding data to a drop-down list control


    (Page 4 of 4 )

    Configuring the data source used by the drop-down

    For this purpose we shall use the same database, but create a second AccessDataSource control, AccessDataControl2, whose configuration details are as shown in this composite picture. We will only use the LastName in the drop-down list alphabetically arranged in the ascending order as shown.

    This configures the AccessDataSource with the following SELECT statement:

    SELECT DISTINCT LastName FROM Employees ORDER BY LastName

    Binding data to drop-down list

    Clicking on the "task arrow" at the top-left of the drop-down list control brings up the tasks list for this control. Clicking on the Choose Data Source... hyperlink opens up the Choose a Data Source section of the Data Source Configuration Wizard as shown. You can click on the Select a data source drop-down to reveal the available data sources configured. Since AccessDataSource2 will be used, choose this source. The Select a data field to display in the DropDownList should only show one item, namely the "LastName." This is the same, by default, for the drop-down's value for the field as shown. Since the data source has been assigned at design time there is no need to write any code.

    The properties of the DropDownList1 control are as shown in this picture. All these assignments are made in the previous dialogue.

    The result of displaying the control by browsing the default.aspx page is as shown in the next picture (the Show Employee Information button was not clicked).

    Summary

    The AccessDataSource control saves a lot of trouble and reduces the labor involved in configuring ODBC or OLEDB connections. However, its use is limited to databases which are not protected. The documentation, however, says that the base class may be used in such cases. Data binding was shown through both code, and at design time. The data source configuration wizard also includes a query designer, although one was not used in the tutorial.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · 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...




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