Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Exercises

12.3(Display Authors Table Application Modification) Modify the DisplayTable application in Section 12.5 to contain a TextBox and a Button that allow the user to search for specific authors by last name. Include a Label to identify the TextBox. Using the techniques presented in Section 12.9, create a LINQ query that changes the DataSource property of AuthorBindingSource to contain only the specified authors.
12.4(Display Query Results Application Modification) Modify the Display Query Results application in Section 12.6 to contain a TextBox and a Button that allow the user to perform a search of the book titles in the Titles table of the Books database. Use a Label to identify the TextBox. When the user clicks the Button, the application should execute and display the result of a query that selects all the rows in which the search term entered by the user in the TextBox appears anywhere in the Title column. For example, if the user enters the search term “Visual,” the DataGridView should display the rows for Simply Visual Basic 2008, Visual Basic 2008 How to Program, Visual C# 2008 How to Program and Visual C++ 2008 How to Program. If the user enters “Simply,” the DataGridView should display only the row for Simply Visual Basic 2008. [Hint: Use the Contains method of the String class.]
12.5

(Baseball Database Application) Build an application that executes a query against the Players table of the Baseball database included in the Databases folder with this chapter’s examples. Display the table in a DataGridView, and add a TextBox and Button to allow the user to search for a specific player by last name. Use a Label to identify the TextBox. Clicking the Button should execute the appropriate query.

12.6

(Baseball Database Application Modification) Modify Exercise 12.5 to allow the user to locate players with batting averages in a specific range. Add a minimumTextBox for the minimum batting average (0.000 by default) and a maximumTextBox for the maximum batting average (1.000 by default). Use a Label to identify each TextBox. Add a Button for executing a query that selects rows from the Players table in which the BattingAverage column is greater than or equal to the specified minimum value and lessthan or equal to the specified maximum value.

12.7

(Project: AdventureWorks Sample Database) In this exercise, use Microsoft’s sample AdventureWorks database. There are several versions available, depending on what version of SQL Server you’re using and your operating system. We used the AdventureWorks LT version of the database—a smaller version with fewer tables and less data than the full version. The files for SQL Server 2008 can be downloaded from

msftdbprodsamples.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24854

The installer allows you to select which version of the database to install.

Use the AdventureWorks database in an application that runs multiple queries on the database and displays the results. First, it should list customers and their addresses. As this is a large list, limit the number of results to ten. [Hint: Use LINQ’s Take clause at the end of the query to return a limited number of results. The Take clause consists of the Take operator, then an Integer specifying how many rows to take.] Second, if a category has subcategories, the output should show the category with its subcategories indented below it. The queries described here require the AdventureWorks tables Address, Customer, CustomerAddress and ProductCategory.

12.8

(Project: AdventureWorks Master/Detail view) Use the Microsoft AdventureWorks database from Exercise 12.7 to createa master/detail view. One master list should be customers, and the other should be products—these should show the details of products the customers purchased, and customers who purchased those products, respectively. Note that there are many customers in the database who did not order any products, and many products that no one ordered. Restrict the drop-down lists so that only customers that have submitted at least one order and products that have been included in at least one order are displayed. The queries in this exercise require the Customer, Product, SalesOrderHeader and SalesOrderDetail tables.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint