tailieunhanh - C# .NET Web Developer's Guide phần 8

vào các dự án ListHost trong Solution Explorer và chọn Set as StartUp dự án để cho phép IDE để làm điều này. 3. Hình cho thấy các trường hợp ngoại lệ xảy ra khi được tái sử dụng cùng một cổng. Hình Các ngoại lệ được tạo ra sau khi một Cố gắng để tái sử dụng một | 552 Chapter 10 using You will need to add these two namespaces to the file to provide data access functionality using using namespace public class dataaccess Set the connection string to connect to the SQL data store private string connection Persist Security Info False User ID user name password password Initial Catalog shopDb Data Source server name Create the method getAllBooks this method will connect to the database and call the stored procedure GetAllBooks public DataSet getAllBooks SqlConnection conn new SqlConnection Create the command object to reference the stored procedure SqlCommand cmd new SqlCommand GetAllBooks conn Here you will use the SQL data adapter so that you can retrieve the data returned by getAllBooks and store it in a DataSet SqlDataAdapter da new SqlDataAdapter cmd DataSet ds new DataSet ds Books Chapter 10 553 Next close the connection to the database and return the resulting DataSet return ds In this section you created the component that you will use to retrieve the data from the database in a dataset. In the next section you will create the component that will function as the shopping cart. Creating This component is a wrapper component for XML. It provides add remove view and clear functionality. The only catch is that items added to the cart must be XmlNodes from Catalog or must adhere to the same document can find this file in its entirety on the CD see in the components folder of the application using System Add support for XML by including the XML namespace using namespace Define the shopping cart class public class xmlShoppingCart private XmlDocument myCart private string elementType This initializes the cart. On page_ load the cart can be initialized .

TỪ KHÓA LIÊN QUAN