Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Send parent-child records in single XML
Message
From
01/12/2006 06:49:22
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
01/12/2006 00:56:04
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01173997
Message ID:
01174040
Views:
12
>Hi ToAll,
>
>is it posibble to convert this to VB.Net?
>
>
>CLOSE DATABASES
>OPEN DATABASE (HOME(2)) + "Northwind\northwind.dbc"
>
>* Create XML
>SELECT 0
>USE northwind!OrderDetails
>SET ORDER TO ORDERID   && ORDERID
>SELECT 0
>USE northwind!Orders
>SET RELATION TO OrderID INTO OrderDetails
>oXA = CREATEOBJECT("XmlAdapter")
>oXA.RespectNesting = .T.
>oXA.AddTableSchema("Orders")
>oXA.AddTableSchema("OrderDetails")
>oXA.ToXML("Orders.xml",,.T.)
>***Modify Command Orders.xml
>
>CLOSE DATABASES ALL
>
>* Load XML
>oXA = CREATEOBJECT("XmlAdapter")
>oXA.LoadXML("Orders.xml",.T.)
>FOR i=1 TO oXA.Tables.Count
>	oXA.Tables(i).Tocursor()
>ENDFOR
>SET
>
>
>
>thanks and regards,
>ryan.

Something like this in C#:
using System;
using System.Data;
using System.Data.OleDb;
using System.IO;

class nestedXML
{
  static void Main()
{
  OleDbConnection con = new OleDbConnection("Provider=VFPOLEDB;Data Source="+
@"C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO 9\SAMPLES\Northwind\northwind.dbc");

OleDbDataAdapter daOrders = new OleDbDataAdapter("SELECT * FROM Orders", con);
OleDbDataAdapter daOrderDet = new OleDbDataAdapter("SELECT * FROM OrderDetails", con);

con.Open();

DataSet ds = new DataSet("VFPDataSet");
daOrders.Fill(ds, "Orders");
daOrderDet.Fill(ds, "OrderDetails");

con.Close();

DataRelation relO2Od = ds.Relations.Add(
  "order2detail", 
  ds.Tables["orders"].Columns["orderID"],
  ds.Tables["OrderDetails"].Columns["orderID"]);

relO2Od.Nested = true;

StreamWriter sw = new StreamWriter(@"c:\temp\VFPOrdersData.xml");
ds.WriteXml(sw, XmlWriteMode.WriteSchema);
sw.Close();
}
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform