Replacing Null Values in a Strongly Typed DataSet

[ Team LiB ] Recipe Replacing Null Values in a Strongly Typed DataSet Problem When a column in a database has a null value, you want the value in the DataSet to be a string indicating that no value is available. Solution Use annotations in the XML schema to control the handling of null values. | Team LiB Recipe Replacing Null Values in a Strongly Typed DataSet Problem When a column in a database has a null value you want the value in the DataSet to be a string indicating that no value is available. Solution Use annotations in the XML schema to control the handling of null values. The sample uses one XSD file The schema used to generate the strongly typed DataSet. The schema is annotated so the null Description values are replaced with the string - no description available - . The annotations are marked in bold in Example 2-25. Example 2-25. File TypedDataSets xml version standalone yes xs schema id CategoriesDS_AnnotatedNull targetNamespace http xmlns mstns http xmlns http xmlns xs http 2001 XMLSchema xmlns msdata urn schemas-microsoft-com xml-msdata xmlns codegen urn schemas-microsoft-com xml-msprop attributeFormDefault qualified elementFormDefault qualified xs element name CategoriesDS_AnnotatedNull msdata IsDataSet true xs complexType xs choice maxOccurs unbounded xs element name Categories xs complexType xs sequence xs element name CategoryID msdata ReadOnly true msdata AutoIncrement true type xs int xs element name CategoryName type xs string xs element name Description type xs string minOccurs 0 codegen nullValue - no description available - xs sequence xs complexType xs element xs choice xs complexType xs unique name Constraint1 msdata PrimaryKey true xs selector xpath . mstns Categories xs field xpath mstns CategoryID xs unique xs element xs schema The sample code creates a strongly typed DataSet based on the Categories table in Northwind. The user specifies whether the one based on the default or annotated schema file is used. In either case data is loaded into the DataSet. A row is added to the Categories table with a .

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
Đã 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.