TAILIEUCHUNG - Storing XML to a Database Field

[ Team LiB ] Recipe 8. Storing XML to a Database Field Problem You need to store XML to a field in a database. Solution Store the contents of the InnerXml of the XmlDocument to the database. You can later load this into an empty XmlDocument with LoadXml( ). | Team LiB Recipe 8. Storing XML to a Database Field Problem You need to store XML to a field in a database. Solution Store the contents of the InnerXml of the XmlDocument to the database. You can later load this into an empty XmlDocument with LoadXml . The schema of table TBL0804 used in this solution is shown in Table 8-4. Table 8-4. TBL0804 schema Column name Data type Length Allow nulls Id int 4 No XmlField nvarchar 4000 Yes The sample code contains five event handlers Sets up the DataTable that contains the text field XmlField containing the XML and the DataAdapter for the table. Write Adds or updates a record in the table with the Id and XmlField entered by the user. Read Loads the XML for the specified Id into an XmlDocument and displays it on the form in the XmlField text box. Sample Generates sample XML data from the Orders table in Northwind and displays it on the form in the XmlField text box. Clear Clears the contents of the Id and XmlField text boxes on the form. The C code is shown in Example 8-7. Example 8-7. File Namespaces variables and constants using System using using using using using using private DataTable dt private SqlDataAdapter da private const String TABLENAME TBL0804 . . . private void StoreXmlFieldForm_Load object sender e String selectText SELECT Id XmlField FROM TABLENAME String insertText INSERT TABLENAME Id XmlField VALUES @Id @XmlField String updateText UPDATE TABLENAME SET XmlField @XmlField WHERE Id @Id Create the data adapter. da new SqlDataAdapter selectText S ql_ConnectString new SqlCommand updateText @Id 0 Id @XmlField .

TÀI LIỆU MỚI ĐĂNG
34    216    1    10-05-2024
46    191    0    10-05-2024
20    201    2    10-05-2024
10    123    0    10-05-2024
75    140    0    10-05-2024
1    121    1    10-05-2024
41    125    0    10-05-2024
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.