Using XML in the .NET Framework "  Chapter 4 137 Figure 4.13  Continued using System.Data.OleDb; namespace XmlDataDocumentProject { class Class1 { static void Main(string[] args) { OleDbConnection myConn = new OleDbConnection("Provider=SQLOLEDB.1;" + "Data Source=localhost;Initial Catalog=Pubs;" + "User ID=sa;Pwd=;"); OleDbCommand myCommand = new OleDbCommand( "SELECT * FROM Authors", myConn); OleDbDataAdapter myAdapter = new OleDbDataAdapter(myCommand); DataSet myData = new DataSet(); myAdapter.Fill(myData); XmlDataDocument myDoc = new XmlDataDocument(myData); Console.WriteLine(myDoc.OuterXml); Console.Write("Press enter to finish..."); Console.ReadLine(); } } } The first few lines in the code establish a connection to the PUBS database on the local instance of SQL Server. Next, a command object is built with the SQL statement SELECT * FROM Authors, and a DataAdapter is created and a DataSet filled with the resulting data. Next, an XmlDataDocument is created and the DataSet is passed as a constructor parameter to the XmlDataDocument. Finally, the OuterXml of the XmlDataDocument is written to the console.The following XML is a sample of what is returned: 155_xml_net_pd_C04.qk  3/6/02  1:57 PM  Page 137