Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the field name and the field value of a row
Message
De
13/01/2007 03:45:44
 
 
À
13/01/2007 03:42:39
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01185330
Message ID:
01185335
Vues:
14
>Essentially, you can use the DataColumn object, like so...
>
>
>DataTable dt = new DataTable();
>dt.Columns.Add("name",typeof(String));
>dt.Columns.Add("datehired", typeof(DateTime));
>dt.Columns.Add("salary",typeof(Decimal));
>dt.Columns.Add("active", typeof(Boolean));
>
>dt.Rows.Add("Kevin Goff", new DateTime(2000, 1, 1), 100000, true);
>dt.Rows.Add("John Doe", new DateTime(2001, 11, 11), 50000, false);
>
>object odcvalue;
>string cColumnName;
>
>foreach (DataRow dr in dt.Rows)
>    foreach (DataColumn dc in dt.Columns) {
>        cColumnName = dc.ColumnName.ToString();
>        odcvalue = dr[dc];
>        // if you want to do something with the object, check the datatype of the column object and
>        // proceed accordingly
>    }
>
>
>
I found there there is no way of obtaining that information from the data row. As you mentioned, we have to go through the datatable route. Given the fact that we are doing a SQLExec command, which returns one record, and make us of loRow to get the field, it is somewhat difficult to create a datatable to collect that information.

When I did was to use my data dictionnary to get the field definitions I need as I obtained more flexibility using that route.

Thanks
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