Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataView/DataSet/DataReader
Message
De
09/01/2007 12:35:16
 
 
À
09/01/2007 12:28:10
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01183234
Message ID:
01183850
Vues:
42
>I'm playing with the following piece of code.
>
>
>using System;
>using System.Text;
>using System.Data;
>using System.Data.OleDb;
>
>namespace MyPlayCode
>{
>    class Program
>    {
>        static void Main(string[] args)
>        {
>            string ConnectionString = @"Provider=VFPOLEDB;Data source=C:\Program Files\Microsoft Visual FoxPro 8\Samples\Data\testdata.dbc;";
>
>            string CommandString = "SELECT * FROM customer where country = 'USA'";
>
>            OleDbDataAdapter DataAdapter = new OleDbDataAdapter(CommandString, ConnectionString);
>
>            DataSet sDataSet = new DataSet();
>
>            DataAdapter.Fill(sDataSet);
>
>            DataTable DTable = sDataSet.Tables[0];
>            int nMaxAmt = 0;
>
>            string sDispStr = "";
>            foreach (DataRow TRow in DTable.Rows)
>            {
>                sDispStr += TRow[0] + ", " + TRow[1] + " – " + TRow[2] + TRow[11].ToString() + "\n";
>                Console.WriteLine(sDispStr);
>                Console.ReadLine();
>
>            }
>
>        }
>    }
>}
>
>
>I think I setup the DataAdpater correctly. But I want to access my field by field name like TRow("custname") or TRow("MaxOrdAmt") like you.
>
>How do I get there from this code? Am I close?

I believe you only have to change to TRow("CustName"). In VB.NET, you also have to use parentheses. Is it working up until the foreach loop?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform