HUsing ADO.NET 2.0 with Microsoft Access Databases - Cengage ...
HUsing ADO.NET 2.0 with Microsoft Access Databases - Cengage ...
HUsing ADO.NET 2.0 with Microsoft Access Databases - Cengage ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Connecting a Database to an Application 5<br />
CONNECTING A DATABASE TO AN APPLICATION<br />
Before an application can access the data stored in a database, you need to connect<br />
the database to the application. You can use the Data Source Configuration<br />
Wizard to make the connection. Figure H.4 shows the procedure you follow<br />
when using the Data Source Configuration Wizard to connect a database to an<br />
application.<br />
Appendix H C5779 39147 Page 5 07/10/06--JHR<br />
HOW TO…<br />
Connect a Database to an Application<br />
1. Open the application’s solution file. Click Data on the menu bar, and<br />
then click Show Data Sources to open the Data Sources window.<br />
2. Click the Add New Data Source link in the Data Sources window. This<br />
opens the Data Source Configuration Wizard dialog box and displays<br />
the Choose a Data Source Type screen. If necessary, click Database. See<br />
Figure H.5. As the figure indicates, the Database option in the dialog<br />
box allows you to connect to a database and choose the database<br />
objects (such as tables and fields) for your application. The option also<br />
creates a dataset that contains the chosen objects.<br />
3. Click the Next button, and then continue using the Data Source<br />
Configuration Wizard to specify the data source. The Wizard will add<br />
several files to the project. The names of the files will appear in the<br />
Solution Explorer window. (Detailed steps for using the wizard can be<br />
found in the Programming Tutorial section of this chapter.)<br />
4. When the Wizard is finished, it adds a dataset to the Data Sources<br />
window. Figure H.6 shows an example of a dataset added to the Data<br />
Sources window in the Morgan Industries application. In this case,<br />
the dataset’s name is EmployeesDataSet, and it contains one table<br />
object and seven field objects. The table object is the tblEmploy table<br />
contained in the Employees database, and the seven field objects<br />
correspond to the seven fields in the table.<br />
FIGURE H.4<br />
How to connect a database to an application