TAILIEUCHUNG - Writing and Reading XML Using a DataSet Object

Writing and Reading XML Using a DataSet Object XML is a convenient format for moving information around. You can write out the contents of the DataTable objects contained in a DataSet to an XML file using the WriteXml() method | Writing and Reading XML Using a DataSet Object XML is a convenient format for moving information around. You can write out the contents of the DataTable objects contained in a DataSet to an XML file using the WriteXml method. The XML file written by this method contains the DataTable column names and values. You can write out the schema of a DataSet object to an XML file using the WriteXmlSchema method. The XML file written by this method contains the structure of the DataTable objects contained in the DataSet. You can also get the XML in a DataSet using the GetXml method which returns the XML in a string. You can read the contents of the DataTable objects in an XML file into a DataSet using the ReadXml method. You can also read the schema contained in an XML file using the ReadXmlSchema method. Note SQL Server also contains extensive built-in XML functionality which you ll learn about in Chapter 16 Using SQL Server s XML Support. Using the WriteXml Method Let s say you have a DataSet object named myDataSet. Assume that myDataSet has a DataTable that contains the CustomerID CompanyName ContactName and Address columns for the top two rows from the Customers table. The following code shows this SqlCommand mySqlCommand SELECT TOP 2 CustomerID CompanyName ContactName Address FROM Customers ORDER BY CustomerID SqlDataAdapter mySqlDataAdapter new SqlDataAdapter mySqlCommand DataSet myDataSet new DataSet Retrieving rows from the Customers table myDataSet Customers You can write out the contents of myDataSet to an XML file using the WriteXml method. For example This writes an XML file named as shown in Listing . xml version standalone yes NewDataSet Customers CustomerID ALFKI CustomerID .

TÀI LIỆU LIÊN QUAN
10    127    1
6    150    1
7    127    1
5    125    1
6    127    1
6    115    1
6    122    1
6    174    1
7    122    1
5    97    1
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.