TAILIEUCHUNG - Reading XML Data Directly from SQL Server

[ Team LiB ] Recipe Reading XML Data Directly from SQL Server Problem You need to read XML data directly from the SQL Server. Solution Use the FOR XML clause in the stored procedure or SQL statement. The C# code is shown in Example 8-8. Example 8-8. File | Team LiB Recipe Reading XML Data Directly from SQL Server Problem You need to read XML data directly from the SQL Server. Solution Use the FOR XML clause in the stored procedure or SQL statement. The C code is shown in Example 8-8. Example 8-8. File Namespaces variables and constants using System using using using using . . . Select statement to read XML directly. String sqlText SELECT FROM Orders FOR XML AUTO XMLDATA Create the connection. SqlConnection conn new SqlConnection Sql_ConnectString Create the command. SqlCommand cmd new SqlCommand sqlText conn Read the XML data into a XML reader. XmlReader xr Read the data from the XML reader into the DataSet. DataSet ds new DataSet xr Discussion SQL Server 2000 introduced support for retrieving data in XML format using the FOR XML clause. The .NET SQL Server data provider SqlCommand object has an ExecuteXmlReader that allows you to retrieve an XML stream directly from SQL Server where it returns an XmlReader that contains the results of the SQL query. The ExecuteXmlReader method can only be used with SQL statements that return XML data such as those with a FOR XML clause. The ExecuteXmlReader method can also be used to return ntext data containing valid XML. For more information about the FOR XML clause see Microsoft SQL Server Books Online. Team LiB

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.