Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the field name and the field value of a row
Message
From
13/01/2007 09:52:50
 
 
To
13/01/2007 04:04:37
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01185330
Message ID:
01185361
Views:
16
>In my case, I have a dataset, which I extract the row from, but I do not have the datatable to collect that information from.

Ah, but you do ... if the DataRow came from a table to begin with, then it has a table property that tells you what that table was. You can then do this:
string ColumnName;
object ColumnValue;
for (int i=0; i < MyRow.Table.Columns.Count; i++)
{
    ColumnName  = MyRow.Table.Columns[i].ColumnName;
    ColumnValue = MyRow[i];
    // -or- ColumnValue = MyRow[ColumnName]; -- either way --
}
~~Bonnie




>>Ok...well, if you found a way, that's all that matters.
>>
>>If you're working with typed datasets, especially built from a schema that was generated from the database, you'd have similar information.
>>
>>I realize your information is coming from a database, I was just using a datatable with different columns as an example.
>
>Yes, as this is a two step process, requiring a datatable to exist, this is why I switched to my own approach.
>
>In my case, I have a dataset, which I extract the row from, but I do not have the datatable to collect that information from.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform