Udostępnij za pośrednictwem


How to: Add a Database Data Source to a Web Test

Before you can add data binding to a Web request, you must add a data source to the Web test. After you add a data source to a Web test, you can bind a Web request to the data. For more information, see How to: Add Data Binding to a Web Request. After you add data binding to a Web request, you must configure the test run to access one or more rows of data. For more information, see How to: Configure Data Binding in a Web Test.

To add the data source to the Web test

  1. In the Web Test Editor, right-click the top node of the Web test and then click Add Data Source.

    The New Test Data Source Wizard appears.

  2. In the Data source name box type a name for your data source.

  3. In the Data source type list click Database.

  4. Click Next.

  5. Select an existing connection, or follow these steps:

    1. Click New Connection.

      The Choose Data Source dialog box appears.

    2. In the Data source list, click the appropriate source for your database.

    3. (Optional) In the Data provider list, click the appropriate provider for your database.

    4. (Optional) Clear the Always use this selection check box.

    5. Click Continue.

      The Connection Properties dialog box appears.

    6. Enter the information to connect to your database.

    7. (Optional) Click the Test Connection button to verify your connection to the database.

    8. Click OK to close the Connection Properties dialog box.

    The connection string to access the database is entered in the wizard.

  6. Click Next.

  7. Under Choose from the available tables for this data source, select the check box next to each table that you want to include in the data source.

  8. Click Finish.

    If your database is a file, for example a Microsoft Access database, a dialog box appears that asks you if you want to add the file to your current project. You can use the following information to help you decide:

    Response

    Result

    Advantage

    Yes

    The file is copied to the project.

    When the project is deployed, there is no extra work that is required.

    No

    The file is not copied to the project. When the project is deployed, you might have to update the path of the file.

    Some data files can be very large, and should be maintained separate from the project. Some data files must be shared among several members of a team, and should be maintained in a central location that all members can access.

  9. Click Yes or No.

    A Data Sources node is added to the Web test, and the database and tables appear in the hierarchy.

  10. On the Filemenu click Save to save the Web test.

See Also

Tasks

Walkthrough: Adding Data Binding to a Web Test

How to: Add a CSV File Data Source to a Web Test

How to: Add an XML File Data Source to a Web Test

Other Resources

Data Binding in Web Tests