Udostępnij za pośrednictwem


Data Adapter Preview Dialog Box

Allows you to see how data will be filled into a dataset when an adapter's SelectCommand object is invoked. Using this dialog box allows you to test that the adapter is returning the data that you expect, that any table mappings work properly, and that there are no errors when you fill the dataset. The dialog box also allows you test the effect of passing different parameter values to the adapter.

Note

In the previous version of Visual Studio, data adapters were used for communicating between an application and a database. While data adapters are still a main component of .NET Framework Data Providers (ADO.NET), TableAdapters are designer-generated components that simplify the process of manipulating data between your application and a database. For more information on working with TableAdapters, see TableAdapter Overview.

Previewing a data adapter is particularly useful if you are going to use it to fill a dataset that was not generated directly from the adapter.

The dialog box appears when you perform either of the following actions:

  • Select Preview Data from the Data menu. This menu is available only when a data adapter has been added to a form or component.

  • Click the Preview Data link at the bottom of the Properties window. This link is available when you are displaying properties for a data adapter.

User Interface Element List

  • Data adapters
    Lists the data adapters available on the form or component you are working with. Select the adapter you want to preview. To show the results of using all data adapters, select <All data adapters>.

  • Fill Dataset
    Executes the command and display the data in the Results box.

    If an error occurs while the data adapter is filling data into the dataset, the error is displayed in a message box. Possible errors include:

    • Data type mismatches.

    • Syntax errors in the SQL statement or stored procedure being executed.

    • Table mapping errors. For example, if an adapter's MissingMappingAction or MissingSchemaAction properties are set to Error, and if the table mappings do not completely describe what to do with mismatched column names in the database and dataset, an error is raised.

    • Connection problems.

  • Parameters
    Displays parameters required for the SQL SELECT statement or the stored procedure referenced in the SelectCommand object of the specified data adapter or adapters. If no parameters are required, this grid is blank.

    Each parameter is displayed as a row in the grid with the parameter name and data type filled in. Enter a value for each parameter in the Value box. Alternatively, if the parameter accepts this, you can select <DEFAULT> or <NULL> from the drop-down list in the Value box.

  • Target dataset
    Specifies the dataset into which the preview command should fill data. You can select from all available datasets in your project or you can select to fill in an untyped dataset (one without a schema).

  • Data tables
    Displays a list of the data tables in the dataset. Select a table name to see the records filled in by the data adapter. (Usually, each data adapter fills one table in the dataset.) If more than one table has been filled, you can select a table in this list to see the results for that table.

  • Results
    Displays the data in the dataset. The box shows how the data will appear after being returned from the database and after any table mappings have been applied. The data in the grid is read-only.

    If there is more than one table in the results, you can view the contents of a specific table by selecting its name in the Data table list.

  • Clear Results
    Clears all data in the selected table. To clear all tables, select each one in the Data tables list and click Clear Results for each one.

See Also

Concepts

Binding Windows Forms Controls to Data in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Binding Controls to Data in Visual Studio

Editing Data in Your Application

Validating Data

Saving Data

Other Resources

Connecting to Data in Visual Studio