//----------------------------------------------------------------------- // This file is part of the Microsoft .NET Framework SDK Code Samples. // // Copyright (C) Microsoft Corporation. All rights reserved. // //This source code is intended only as a supplement to Microsoft //Development Tools and/or on-line documentation. See these other //materials for detailed information regarding Microsoft code samples. // //THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY //KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE //IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A //PARTICULAR PURPOSE. //----------------------------------------------------------------------- #using #using #using #using using namespace System; using namespace System::Data; using namespace System::Xml; using namespace System::Data::SqlClient; ref class readandwritexml { public: void Run() { try { SqlConnection^ myConnection = gcnew SqlConnection("server=(local)\\SQLExpress;Integrated Security=SSPI;database=northwind"); SqlDataAdapter^ mySqlDataAdapter1 = gcnew SqlDataAdapter("select * from customers", myConnection); SqlDataAdapter^ mySqlDataAdapter2 = gcnew SqlDataAdapter("select * from orders", myConnection); DataSet^ myDataSet = gcnew DataSet(); mySqlDataAdapter1->Fill(myDataSet,"Customers"); mySqlDataAdapter2->Fill(myDataSet,"Orders"); String^ strXMLData = myDataSet->GetXml(); String^ strXMLSchema = myDataSet->GetXmlSchema(); Console::WriteLine("Select View Source to see XMLSchema"); Console::WriteLine(strXMLSchema); Console::WriteLine(""); Console::WriteLine("Data"); Console::WriteLine(strXMLData); myConnection->Close(); } catch(Exception ^ e) { Console::WriteLine(e->ToString()); } } }; void main() { readandwritexml ^ myreadandwritexml = gcnew readandwritexml(); myreadandwritexml->Run(); }