TAILIEUCHUNG - ASP.NET 4 Unleased - p 86

Niêm yết 18,35 sử dụng sử dụng sử dụng sử dụng sử dụng hệ thống; ; ; ; ; public class InsertMovie {tin tĩnh chỉ đọc chuỗi _conString; công tĩnh SqlDataReader GetMovies () {/ / Khởi tạo kết nối SqlConnection con = new SqlConnection (_conString) | 824 CHAPTER 18 Using the ObjectDataSource Control In Listing the Inserted event handler checks for an exception. If an exception exists the exception is handled and an error message displays see Figure . FIGURE Handling method errors gracefully. The page in Listing is bound to the component in Listing . LISTING using System using using using using public class InsertMovie private static readonly string _conString public static SqlDataReader GetMovies Initialize connection SqlConnection con new SqlConnection _conString From the Library of Wow eBook Handling ObjectDataSource Control Events 825 Initialize command SqlCommand cmd new SqlCommand con SELECT Id Title Director FROM Movies Execute command return public static void Insert string title string director Initialize connection SqlConnection con new SqlConnection _conString Initialize command SqlCommand cmd new SqlCommand con INSERT Movies Title Director VALUES @Title @Director Add parameters @Title title @Director director Execute command using con static InsertMovie _conString Movies .ConnectionString 18 You can create an exception by entering a new movie record and not supplying a value for one of the fields. For example the Title column in the Movies database table does not accept null values. From the Library of Wow eBook 826 CHAPTER 18 Using the ObjectDataSource Control NOTE Instead of handling errors at the level of the DataSource control you can handle errors at the level of the DataBound control. For example the DetailsView control supports an Itemlnserted event. Handling the Objectcreating Event By default the ObjectDataSource control .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.