home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / adoplus / readandwritexml.aspx < prev    next >
Encoding:
Text File  |  2000-06-09  |  2.3 KB  |  40 lines

  1.  
  2. <%@ Register TagPrefix="Acme" TagName="SourceRef" Src="/quickstart/util/SrcRef.aspx"%>
  3.  
  4. <!-- #include virtual="/quickstart/include/header.inc" -->
  5.  
  6. <h4>ADO+: Reading and Writing XML</h4>
  7. <p>
  8. <hr>
  9. <p>
  10. There are essentially two parts to XML as it relates to ADO+ and the DataSet: Schema and Data.
  11. <p>
  12. <b>Schemas</b>
  13. <br>Schemas, or the tables, columns, constraints and so forth, of a DataSet can be defined in severals ways. One method is to create them using properties and methods (PrimareyKey, Table.Add, Column.Add, and so on). This establishes a schema within your DataSet that can be used as a container to hold data. Another way is to use the SQLDataSetCommand or ADODataSetCommand.  When you use these commands, if the schema does not exist in a DataSet, it is created for you (see: SchemaMappingAction for specifics about when to ignore, append or throw an exception on mismatched schemas). Essentially a DataSet can have either a dynamic or fixed schema through its lifetime.
  14. <p>
  15. XML is an intrinsic element of ADO+. Several methods that support XML have been implemented. The XMLSchema property is also used to work with schemas. This property allows you to set or get the schema of a DataSet using an XSD or XDR schema. (Note: you can only set XDR schemas; but the property always returns an XSD schema.) For example, if you load a DataSet from the database, you could get an XSD schema from it:
  16. <p>
  17. <div class=code>
  18. Response.Write dsCustomersDataset.XmlSchema;
  19. </div>
  20. <p>
  21. This return an XSD compliant XML schema for the schema in your DataSet. Conversly, setting this property returns a DataSet compliant with a given XSD schema.
  22. <p>
  23. <b>Data</b>
  24. <p>
  25. Data is also simply retrieved through the XmlData property. The XmlData property can set or get XML compliant data.
  26. <p>
  27. <div class=code>
  28. Response.Write dsCustomersDataset.XmlData;
  29. </div>
  30. <p>
  31. The sample below loads data from a database, and then outputs the XSD Schema and XML data. It also creates another DataSet using the same XML data.
  32. <p>
  33. <Acme:SourceRef 
  34.   RunSample="/quickstart/howto/samples/adoplus/cs/ReadAndWriteXML.aspx" 
  35.   ViewSource="/quickstart/howto/samples/adoplus/cs/ReadAndWriteXML.src"
  36.   Icon="/quickstart/images/genicon.gif"
  37.   Caption="ReadAndWriteXML.aspx"
  38.   runat="server" />
  39. </a>
  40.