TAILIEUCHUNG - Apress-Visual CSharp 2010 Recipes A Problem Solution Approach_4

Ví dụ sau đây cho thấy làm thế nào để lấy kết quả như XML bằng cách sử dụng mệnh đề FOR XML và phương pháp ExecuteXmlReader: sử dụng sử dụng sử dụng sử dụng hệ thống; ; ; ; | CHAPTER 9 DATABASE ACCESS The Code The following example demonstrates how to retrieve results as XML using the FOR XML clause and the ExecuteXmlReader method using System using using using namespace J . class Recipe09_08 . public static void ConnectedExample Create a new SqlConnection object. using SqlConnection con new SqlConnection Configure the SqlConnection object s connection string. @ Data Source . sqlexpress Database Northwind Integrated Security SSPI Create and configure a new command that includes the FOR XML AUTO clause. using SqlCommand com 1 . Ill com. CommandText SELECT CustomerID CompanyName FROM Customers FOR XML AUTO Open the database connection. con. Open Execute the command and retrieve an XmlReader to access the results. using XmlReader reader - while Element if . . . for int i 0 i i . 1 . .1 i 0 1 450 CHAPTER 9 DATABASE ACCESS Move the XmlReader back to the element node. public static void DisconnectedExample XmlDocument doc new XmlDocument Create a new SqlConnection object. using SqlConnection con new SqlConnection Configure the SqlConnection object s connection string. @ Data Source . sqlexpress Database Northwind Integrated Security SSPI Create and configure a new command that includes the FOR XML AUTO clause. SqlCommand com com. CommandText SELECT CustomerID CompanyName FROM Customers FOR XML AUTO Open the database connection. con. Open Load the XML data into the XmlDocument. Must first create a root element into which to place each result row element. XmlReader reader

TỪ KHÓA LIÊN QUAN
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.