using System; using System.Data; using System.Data.OleDb; namespace RelatedDataset { class Class1 { [STAThread] static void Main(string[] args) { string strcon,strsql1,strsql2; strcon = @"Provider=VFPOLEDB; Data Source=C:\Program Files\Microsoft Visual FoxPro 7\Samples\Data\testdata.dbc"; strsql1 = "select * from customer"; strsql2 = "select * from orders"; DataSet ds = new DataSet("testdata"); ds.Tables.Add("customer"); ds.Tables.Add("orders"); OleDbConnection conn = new OleDbConnection(strcon); conn.Open(); OleDbDataAdapter daCustomer = new OleDbDataAdapter(strsql1, conn); OleDbDataAdapter daOrders = new OleDbDataAdapter(strsql2, conn); daCustomer.Fill(ds.Tables["customer"]); daOrders.Fill(ds.Tables["orders"]); conn.Close(); /* Relation in .Net is more flexible than VFP's but that is not obvious here. We're doing a simple relation*/ DataRelation myRel = new DataRelation("CustomerOrders", ds.Tables["customer"].Columns["cust_id"], ds.Tables["orders"].Columns["cust_id"], false); ds.Relations.Add(myRel); foreach (DataRow row in ds.Tables["customer"].Rows) { Console.WriteLine(row["cust_id"]); /* Get all child rows into an array DataRow[] aRows = row.GetChildRows(myRel); for (int childs=0;childs<aRows.Length;childs++) { Console.WriteLine("\t{0}\t{1}", aRows[childs]["order_id"], aRows[childs].GetParentRow(myRel)["company"]); } */ /* or just loop the collection */ foreach (DataRow orderRow in row.GetChildRows(myRel)) { Console.WriteLine("\t{0}\t{1}", orderRow["order_id"], orderRow.GetParentRow(myRel)["company"]); } } /* Add a calculated column to orders. In VFP it's like (and in VFP there are at least 3 ways): alter table myOrders add column myContact c(50) select Customer scan update myOrders set myContact = Customer.Contact where cust_id = Customer.Cust_id endscan */ ds.Tables["orders"].Columns.Add("myContact", typeof(string), "Parent(CustomerOrders).Contact"); /* List orders table */ foreach(DataRow orderRow in ds.Tables["orders"].Rows) { Console.WriteLine("OrderID:{0}\tContact:{1}", orderRow["order_id"],orderRow["myContact"]); } } } }As per creating a table, Create Table, Alter table etc DML commands are available through VFPOLEDB.