TAILIEUCHUNG - ASP.NET 4 Unleased - p 96

Sau khi bạn đã thêm các loại, bạn có thể sử dụng nó giống như bất kỳ loại SQL Server bản địa khác. Ví dụ, bạn có thể tạo một bảng cơ sở dữ liệu mới với lệnh sau đây: CREATE TABLE DBMovies (ID INT IDENTITY, Phim DBMovie) | 924 CHAPTER 19 Building Data Access Components with Creating the User-Defined Type After you have loaded the DBMovie assembly you can create a new user-defined type from the assembly. Execute the following command CREATE TYPE EXTERNAL NAME If you need to delete the type you can execute the following command DROP TYPE DBMovie After you have added the type you can use it just like any other SQL Server native type. For example you can create a new database table with the following command CREATE TABLE DBMovies Id INT IDENTITY Movie DBMovie You can insert a new record into this table with the following command INSERT DBMovies Movie VALUES Star Wars George Lucas Finally you can perform queries against the table with queries like the following SELECT Id Movie FROM DBMovies WHERE SELECT MAX FROM DBMovies SELECT Movie FROM DBMovies WHERE LIKE g I find the fact that you can execute queries like this truly amazing. Building a Data Access Layer with a User-Defined Type In this final section let s actually do something with our new user-defined type. We create a new data access component that uses the DBMovie class and an page that interfaces with the component. Before we can do anything with the DBMovie type we need to add a reference to the assembly to our application. In Visual Web Developer select Website Add Reference and browse to the . Alternatively you can create an application root Bin folder and copy the into the Bin folder. Our new data access component is contained in Listing . LISTING App Code using System using using using using From the Library of Wow eBook Building Database Objects with the .NET Framework 925 public class DBDataLayer private static readonly string _connectionString public List DBMovie .

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.