Converting database data to XML format

From , 3 Years ago, written in C++, viewed 183 times.
URL https://pastebin.vip/view/d54e99a6
  1. #include "stdafx.h"
  2.  
  3. using namespace System;
  4. using namespace System::Configuration;
  5. using namespace System::Data;
  6. using namespace System::Data::SqlClient;
  7. using namespace System::Xml;
  8.  
  9. void Navigate ( XmlNode ^node, int depth )
  10. {
  11.         if ( node == nullptr )
  12.                 return;
  13.  
  14.         Console::WriteLine ( depth );
  15.         Console::WriteLine ( node->NodeType.ToString() );
  16.         Console::WriteLine ( node->Name );
  17.         Console::WriteLine ( node->Value );
  18.  
  19.         if ( node->Attributes != nullptr )
  20.         {
  21.                 for ( int i = 0; i < node->Attributes->Count; i++ )
  22.                 {
  23.                         Console::WriteLine ( node->Attributes[i]->Name );
  24.                         Console::WriteLine ( node->Attributes[i]->Value );
  25.                 }
  26.         }
  27.  
  28.         Navigate ( node->FirstChild, depth+1 );
  29.         Navigate ( node->NextSibling, depth );
  30. }
  31. void main()
  32. {
  33.         XmlDocument ^doc = gcnew XmlDocument();
  34.  
  35.         SqlConnection ^connect = gcnew SqlConnection();
  36.  
  37.         connect->ConnectionString = "SQLConnection";
  38.         SqlDataAdapter ^dAdapt = gcnew SqlDataAdapter();
  39.         DataSet ^dSet          = gcnew DataSet();
  40.         dAdapt->SelectCommand  = gcnew SqlCommand ( "SELECT * FROM Authors", connect );
  41.  
  42.         dAdapt->Fill ( dSet, "Authors" );
  43.         XmlDataDocument ^doc1 = gcnew XmlDataDocument ( dSet );
  44.  
  45.         Navigate ( doc1->DocumentElement, 0 );
  46. }
  47.  

Reply to "Converting database data to XML format"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website