TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P15
Professional Special Edition- P15:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | Advanced Relational Data Management in .NET leads to another menu page that contains links to all the examples for this chapter Accessing Complex Data The relational data access examples in the previous chapter were fairly simple concentrating on extracting data from a single table and multiple tables into the DataSet and DataReader objects. However often the results we want are not just rows from a single table. They may require a more complex SQL query that joins several tables or they might be the result of running a stored procedure within the database. In this section we ll look at some examples that use both complex SQL statements and stored procedures to return sets of rows or just individual values from a data source. The first shows how we can use a DataReader object to efficiently extract the data for display and the second uses the DataSet object. Accessing Complex Data with a DataReader We saw in the previous chapter how the DataReader object can be used to quickly and efficiently extract a rowset from a data store. We simply create a Connection object use it to create a Command object for this connection and then call the ExecuteReader method of the Command object. It returns the new DataReader object. The example code like many of the relational data access examples in the previous and in this chapter uses a separate user control that exposes the specific connection strings for our database server. We described this control in the previous chapter and we insert it into our page using -- insert connection string script -- wrox connect id ctlConnectStrings runat server Remember to edit this file in the data-access global folder of the samples before running the samples on your own server. And as in the previous chapter the example page uses some server-side div elements to display the connection string the SELECT command we re using and any error message. There is also an ASP DataGrid control to display the results div Connection .
đang nạp các trang xem trước