Examining a SQL Data Source
A SQL data source is not the same as a SQL data connection.
A data connection only has knowledge of the database to which it is connecting. A SQLDataSource
control uses a defined data connection, and also encapsulates how a
control will interact with the database by allowing you to define the SELECT, INSERT, UPDATE,
and DELETE SQL statements.
A SQLDataSource control was automatically created
when you dragged the authors table onto the design surface in the previous lesson.
1. You will now redefine the SELECT statement that was automatically set when
you added the GridView control. Open the SqlDataSource
Tasks menu and select Configure Data Source.
Notice that a pubsConnectionString1 connection string has already been defined for you. This resides in your web.config file and was automatically added by VWD
when you dragged the authors table onto the design surface, adding GridView and
You can examine your web.config file and view the XML that contains these
settings. This allows you to change your connection string without
modifying your application.
The XML below is what you would find in your web.config file regarding this data connection:
<add name="pubsConnectionString1" connectionString="Server=localhost\sqlexpress;
InitialCatalog=pubs;Integrated Security=True" providerName="System.Data.SqlClient"/>
2. Click Next to arrive at the Configure the
Select Statement step. Notice how you can modify which columns are selected,
add a WHERE clause, etc. You will do this in the next lesson.
3. If you have time, feel free to click the Next button and test the query. Close the dialog by clicking Cancel.
Powered By ASP.NET v2.0