tailieunhanh - Querying Document In Your Sever
Querying Data Now that you can control access to your application, you can turn your attention to querying and maintaining data. You will useWeb Server Data controls to connect to the database, query data, and maintain the data | Querying Data Now that you can control access to your application you can turn your attention to querying and maintaining data. You will useWeb Server Data controls to connect to the database query data and maintain the data in a manner similar to that used by the Windows Forms application you built in Chapter 24 Working with Data Binding and DataSets. Displaying Customer Information In the following exercises you will fetch all of the rows in the Customers table in the Microsoft SQL Server Northwind Traders database and display them in a GridView. The first task is to create a connection that you can use to connect to the Northwind database. NOTE This exercise assumes that you have completed the exercises in Chapter 23 Using a Database on your computer. Create a connection to the Northwind Database 1. Display the page in the Design View window. Delete the label displaying This form will be implemented later. 2. In the Toolbox expand the Data category. Add a SqlDataSource control to the Web form. 3. Click anywhere in the form to hide the SqlDataSource Tasks menu that appears. A control called SqlDataSourcel is added to the Web form. The SqlDataSource control is a Web Server control that performs the same tasks as a data source in a Windows Forms application. NOTE Although the SqlDataSource control appears on the Web form at design time it will not be visible when the Web form runs. 4. Using the Properties window change the ID property of SqlDataSourcel to CustomerInfoSource. 5. Select the CustomerInfoSource control on the Web Form. Click the Smart Tag icon to display the SqlDataSource Tasks menu and then click the Configure Data Source link. The Configure Data Source Wizard appears. This is very similar but not identical to the wizard you saw in Chapter 23. You will use it to create a connection to the database and fetch the data from the Customers table. 6. Click the New Connection button. Use the Add Connection page to create a new connection .
đang nạp các trang xem trước