Export (0) Print
Expand All
Expand Minimize

Configure Data Source Dialog Box - SqlDataSource 

The Configure Data Source - SqlDataSource dialog box helps you to configure a SQL data source when you want to display relational 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.

Relational data includes Microsoft SQL Server databases, Oracle databases, OLE DB data sources, or Open Database Connectivity (ODBC) data sources.

Security noteSecurity Note

If possible, connect to an instance of SQL Server using Windows Integrated security instead of using an explicit user name and password. This helps avoid the possibility of your connection string being compromised and your user ID and password being exposed. For more information, see the "Securing Access to a Data Source" 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
  1. In Visual Web Developer, open an ASPX page.

  2. Switch to Design view.

  3. 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.

  4. Right-click the control and click Show Smart Tag.

  5. In the tasks window that appears, from the Choose Data Source drop-down list, select <New data source…>.

    NoteNote

    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.

  6. Under Where will the application get data from, click Database.

  7. In the Specify an ID for the data source box, type a data source ID.

    The default ID is SqlDataSource1.

  8. Click OK.

    An SqlDataSource control is automatically created on your page, and the Configure Data Source - SqlDataSource1 window opens.

To access this dialog box directly from an SqlDataSource control
  1. In Visual Web Developer, open an ASPX page.

  2. Switch to Design view.

  3. From the Data group of the Toolbox, drag a SqlDataSource control onto the page.

  4. In the tasks window, click Configure Data Source.

    The Configure Data Source - SqlDataSource1 window opens.

    After you configure the SqlDataSource 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

UI Elements

Which data connection should your application use to connect to the database?

This element appears in the Choose Your Data Connection step of the wizard.

Specifies the connection to use for your database. You can select from a list of existing connections or databases, or you can click New Connection to open the Choose Data Source wizard.

In the Choose Data Source wizard, you can select a data source type and provider, and build a connection string in the Add Connection window. You can optionally select to save your connection string stored in your Web.config file.

Security noteSecurity Note

Do not store connection strings in a page, or as plain text in the Web.config file. For more information, see the "Connection Strings" section in Securing Data Access.

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 select 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

Community Additions

ADD
Show:
© 2014 Microsoft