Hi tgregory,
Looks like this got messed up somewhere between me and the printer. Here's the proof text I have of this example. As far as I can see it works with the download for Chapter 7 but you'll need to copy site.master from the full site directory to C:\BegASPNET2\Chapters\Begin\Chapter07 as it appears to be missing in the download.
Dan
1. Open the web site for the chapter (C:\BegASPNET2\Chapters\Begin\Chapter07) and create a Web Form called Fixtures.aspx in the siteâs root using the web form template with the site master page and with code in a separate page. Switch to Design View and type Fixtures in the content panel.
2. From the Data section of the toolbar (see Figure 7-5), drag a SqlDataSource control to the middle of the content pane. You may have to scroll down to see the new control
3. Click the small arrow at the top right of the control to open the smart task panel (if it isn't already open as shown in Figure 7-6) and click Configure Data Source. A wizard will start and in the first dialog click New Connection.
4. Set the data source to Data Source for a Microsoft SQL Server Database file and click Continue. For the Database File Name, browse to your App_Data folder and select WroxUnited.mdf. Stick with the default Windows Authentication. Click the Test Connection button to be sure the file was spelled correctly and all is in working then press OK.
5. Click Next and, for this example, do not save the connection in the application file. (A connection string to this db file is already saved in web.config)
6. Click Next and in the next dialog box accept the choice to specify columns from a table. From the drop-down list select the Fixtures table. Then select all of its fields by checking the asterisk (*) choice in the columns panel. See Figure 7-7 for an example.
7. Click Next and in the last step of the wizard you will have an opportunity to test your query. You should see several records and fields appear in the panel as in Figure 7-8. Click Finish.
8. Run the page and observe that although you have created a data source control there is no rendering. That will come when you add a data-bound control.
9. Close the browser and click Source View in VWD. Take a look at what VWD built for you in the SqlDataSource control. The Fixtures.aspx page will appear as follows in Source View. Instead of (local)\SQLExpress your server may be identified with a period (full stop) as .\SQLExpress:
<%@ Page Language="C#" MasterPageFile="~/site.master" AutoEventWireup="false" CodeFile="Fixture.aspx.cs" Inherits="Fixture" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=C:\BegASPNET2\Chapters\Begin\Chap ter07\app_Data\WroxUnited.mdf; Integrated Security=True;
User Instance=True" providerName="System.Data.SqlClient"
SelectCommand="SELECT * FROM [Fixtures]">
</asp:SqlDataSource>
</asp:Content>
Dan Maharry
Read the feed at
http://feeds.feedburner.com/dansarchive