Configure Data Source Dialog Box - AccessDataSource
The Configure Data Source - AccessDataSource dialog box helps you to configure a Microsoft Access data source when you want to display data in an ASP.NET Web server control that supports data binding. The title of the dialog box changes according to the ID of the data source control.
Microsoft Access databases support sorting, filtering, and paging when data is returned as a DataSet object.
Security Note: |
---|
Microsoft Access databases (.mdb files) include fewer security features than SQL Server databases. Access databases are not recommended for production Web sites. However, if you have reason to use an .mdb file as part of your Web application, follow the guidelines in the "Microsoft Access Databases" section in Securing Data Access. |
Web server controls that support data binding include, but are not limited to, the following:
To access this dialog box from an ASP.NET Web server control
In Visual Web Developer, open an ASPX page.
Switch to Design view.
From the Toolbox, drag one of the controls from the previous list onto the page. For example, from the Standard group of the Toolbox, drag a GridView control onto the page.
Right-click the control and click Show Smart Tag.
In the tasks window that appears, from the Choose Data Source drop-down list, select <New data source…>.
Note
Some controls only allow you to click Choose Data Source, after which you select <New data source…> from the Select a data source drop-down list.
The Data Source Configuration Wizard opens.
Under Where will the application get data from, click Access Database.
In the Specify an ID for the data source box, type a data source ID.
The default ID is AccessDataSource1.
Click OK.
An AccessDataSource control is automatically created on your page and the Configure Data Source - AccessDataSource1 wizard opens.
To access this dialog box directly from an AccessDataSource control
In Visual Web Developer, open an ASPX page.
Switch to Design view.
From the Data group of the Toolbox, drag an AccessDataSource control onto the page.
Right-click the control and click Show Smart Tag.
In the tasks window that appears, click Configure Data Source.
The Configure Data Source - AccessDataSource1 window opens.
After you configure the AccessDataSource control, you can bind it to any of the Web server controls in the list above by specifying the data source ID in the Choose Data Source drop-down list, or in the DataSourceID property of the Web server control.
For more information about data binding, see ASP.NET Data Access Overview, or the following task-oriented topics.
Tasks
Walkthrough: Creating a Web Page to Display Access Database Data
How to: Connect to an Access Database Using the AccessDataSource Control
How To: Secure Connection Strings when Using Data Source Controls
How to: Bind to Data in a Templated Control in Visual Studio
UI Elements
Microsoft Access data file
This element appears in the Choose a Database step of the wizard.Specifies the relative path to the Microsoft Access database file you want to bind to the control. If you store your database files in the local App_Data folder, then the format of the relative path would be similar to the following:
~/App_Data/sampleAccessDatabase.mdb
How would you like to retrieve data from your database?
This element appears in the Configure the Select Statement step of the wizard.Specifies a select statement to use when obtaining data from the database. You can choose from the following options:
Specify a custom SQL statement or stored procedure
Click Next to build a custom SQL statement or select a stored procedure if you have one configured for your Web site. The QueryBuilder button provides a user interface for creating the SELECT statement. You can test your query after clicking Next.
Specify columns from a table or view
Select the table name, and the columns of data to obtain. You can further define your SELECT statement using the WHERE, ORDER BY, and Advanced buttons. The select statement that you build is visible under SELECT statement. You can test your query after clicking Next.
See Also
Concepts
ASP.NET Data-Bound Web Server Controls Overview
Binding to Data Using a Data Source Control
Binding Data to the TreeView Web Server Control
Data-Binding Expressions Overview