Skip to Content
ASP.NET 3.5 For Dummies®
book

ASP.NET 3.5 For Dummies®

by Ken Cox
February 2008
Intermediate to advanced
428 pages
8h 52m
English
For Dummies
Content preview from ASP.NET 3.5 For Dummies®

6.2. Using the SqlDataSource Control

The SQLDataSource control is a user-friendly way of working with Microsoft's ADO.NET data handling technology. It does much of the grunt work for you, such as opening a connection to the database, executing a SQL statement, fetching the data, and closing the data connection.

6.2.1. Adding and configuring a SqlDataSource control

You need a working SqlDataSource control so that other controls, such as GridView, FormView, and ListView, can use it for their data needs. To add a SqlDataSource control to your page, follow these steps:

  1. Add a single file ASP.NET Web Form (don't use the Place Code in Separate File option) called starter.aspx to your project.

  2. Drag a SqlDataSource control from the Data category of the Toolbox and drop it on the page.

  3. Click the Smart Tag button and select Configure Data Source.

    The Configure Data Source Wizard appears.

  4. From the drop-down list, choose the northwnd.mdf data connection and then click Next.

  5. Accept (that is, leave checked) the offer to save the connection string in the Save the Connection String screen, and then click Next.

  6. In the Configure the Select Statement dialog box, choose the Customers table from the drop-down list.

    The columns (fields) in the Customers table appear in the Columns box.

  7. In the Columns box, select the check box for the asterisk.

    This indicates that you want to select all the columns for the query.

  8. Click the Advanced button.

    The Advanced SQL Generation Options dialog box appears, as shown in Figure ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 Unleashed

ASP.NET 3.5 Unleashed

Stephen Walther
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9780470195925Purchase book