| |||||
Introduction to the AccessDataSource ControlControls You Can Use on Web Forms ASP.NET Data Source Controls AccessDataSource Control The AccessDataSource control enables you to retrieve and/or modify data from a Microsoft Access database ( .mdb file ) with minimal coding. The data can then be displayed using any HTML or Web server control that supports binding to data, or can be updated using data-bound controls that support in-place editing, such as the GridView, FormView, and DetailsView controls. The AccessDataSource control inherits most of its properties from the SqlDataSource class, and includes a DataFile property that simpifies connecting to a Microsoft Access database. Connecting to a Database using the AccessDataSource ControlBasically, to connect to a Microsoft Access database using the AccessDataSource control, all you need to do is set the location of the Access .mdb file, using the DataFile property. The AccessDataSource takes care of the underlying connection to the database. The DataFile property expects a universal naming convention ( UNC ) directory path that points to an Access database file. For more information on acceptable path values, see DataFile in the class library. While the AccessDataSource supports both the ConnectionString and ProviderName properties, note that these are meant only for obtaining the values of said properties. You need not set the ConnectionString or the ProviderName properties of the control. In fact, attempting to set either property raises an exception. The AccessDataSource control is configured to use the System.Data.OleDb .NET Data Provider, which in turn uses the Microsoft.Jet.OLEDB.4.0 provider to connect to Access databases. The connection string is automatically generated using this default provider, along with the given DataFile value.
The following example demonstrates how you can use a root-relative path ( "~/directory/filename.mdb" ) to connect to an Access database that is located in the App_Data folder of the current Web application. <asp:accessdatasource id="plans" runat="server"
datafile="~/app_data/plans.mdb"
selectcommand="SELECT Design, Model, Description, PlanId FROM Plans
WHERE Type in ( 'English', 'French', 'Tudor', 'Victorian' )" />
See AlsoAdding AccessDataSource Controls to a Web Forms Page |
| ||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme