13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Test<strong>in</strong>g the XmlRecordsetWriter ClassFor .<strong>NET</strong> Framework applications, us<strong>in</strong>g the XmlRecordsetWriter class is no big deal.You simply <strong>in</strong>stantiate the class and call its methods, as shown here:void ButtonLoad_Click(object sender, System.EventArgs e){// Create and display the <strong>XML</strong> documentCreateDocument("adors.xml");UpdateUI("adors.xml");}void CreateDocument(str<strong>in</strong>g filename){DataSet ds = LoadDataFromDatabase();XmlRecordsetWriter writer = newXmlRecordsetWriter(filename);writer.WriteRecordset(ds);}Figure 4-11 shows the output of a sample application that creates the <strong>XML</strong> file and thendisplays it <strong>in</strong> a text box on the <strong>for</strong>m.Figure 4-11: An ADO <strong>XML</strong> Recordset object that has just been created and its contentsdisplayed <strong>in</strong> a text box on the <strong>for</strong>m.The source DataSet object is fetched from the SQL Server Northw<strong>in</strong>d database byexecut<strong>in</strong>g the follow<strong>in</strong>g query:SELECT employeeid, firstname, lastname FROM employeesThe <strong>XML</strong> file that is created <strong>in</strong> this way is successfully recognized by ADOdrivenapplications, as shown <strong>in</strong> Figure 4-12.146

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!