Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Easy in VFP !!!
Message
De
15/07/2005 03:26:38
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
Divers
Thread ID:
01032196
Message ID:
01032929
Vues:
29
David,
I wrote a code that's much longer than what it could be but anyways metrics would win:)
Cetin

>Cetin,
>
>(this post done with just a little tongue in cheek.. no slam of your code or .Net intended *g*)
>
>VFP code:
>
>open database "C:\Program Files\Microsoft Visual FoxPro 7\Samples\Data\testdata.dbc"
>use customer
>use orders in 0 order cust_id
>set relation to cust_id into orders
>
>scan
>   ? customers.cust_id
>   select orders
>   scan while cust_id = customers.cust_id
>      ? chr(9), orders.order_id, chr(9), customers.company
>   endscan
>endscan
>
>
>
>C# code:
>
>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();
>
>    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"]);
>        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"]);
>     }
>    }
>   }
>  }
>}
>
>
>
>Metric        VFP     C#
># characters  330   1413
># lines        12     51
>
>
>C# takes 4.28 times as many characters and 4.25 times as many lines of code.
>
>Thanks for the reminder about why I switched primary languages from C/C++ to Xbase 14 years ago.
>
>I wonder how many keyboard manufacturers (excessive keyboard wear), disk drive manufacturers (extra storage space) and orthopaedic surgeons (carpal tunnel repair) have bought Microsoft stock because of .Net lately? *bg*
Ç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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform