This documentation is archived and is not being maintained.

Creating Data Adapters Using a Wizard

The Data Adapter Configuration Wizard provides the simplest and most flexible way to create data adapters. For details, see Data Adapter Configuration Wizard.

To create a data adapter using the Data Adapter Configuration Wizard

  1. Open the form or component you are creating in the appropriate designer.
  2. From the Data Tab of the Toolbox, drag an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object onto the design surface.

    The designer adds an instance of the adapter to the form or component and launches the Data Adapter Configuration Wizard.

  3. In the wizard, do the following:
    1. In the second page, create or choose a connection. For more information about creating connections, see Creating ADO.NET Connection Objects.
      Security Note   Storing connection-string details (such as the server name, user name, and password) can have implications for the security of your application. Using Windows Integrated Security is a more secure way to control access to a database. For more information, see Database Security.
    2. In the third page, specify whether the adapter should use SQL statements or stored procedures to read and write data. Choose one of the options listed in the following table.
      Use SQL statementYou will define an SQL SELECT statement that the adapter will use to populate a table in the dataset. Based on your SELECT statement, the wizard will also generate UPDATE, INSERT, and DELETE statements for updating the data source.
      Use newly created stored proceduresYou specify a SELECT statement, and the wizard creates stored procedures from the statement to read and update the data source. If the provider does not support this option, it is grayed out.
      Use existing stored proceduresYou will specify existing stored procedures that the adapter will use to read and update the data source.

      The choice you make determines what appears on the following pane.

    3. In the fourth page, either create the SELECT statement or select the existing stored procedures. For assistance building the SQL statement, click SQL Builder to launch the Query Builder.
      Note   You can create a query with a parameter placeholders in the WHERE clause, which will be filled with information you gather at run time. For details, see Parameters in Data-Adapter Commands.

    When you have finished the wizard, it generates an instance of a connection object with the information you specified in the second page.

  4. If you want to change the name of the adapter and connection, select them individually in the designer and give them each a new name in the Properties window.
  5. If you want to see what data the adapter will fill into the dataset, you can preview it. For details, see Previewing Data-Adapter Results.

You can also create and configure an adapter manually. To do so, you must already have a connection object available. Part of configuring the data adapter involves establishing table mappings between tables in the data source and the dataset. For details, see Creating and Configuring Data Adapters Manually.

See Also

Creating Data Adapters Using Server Explorer | Creating and Configuring Data Adapters Manually | Populating a DataSet from a DataAdapter | Previewing Data-Adapter Results | Configuring Parameters for Data Adapters