Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading a row in a DataSet
Message
From
19/09/2003 08:05:31
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
 
 
To
18/09/2003 17:17:19
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00830470
Message ID:
00830613
Views:
25
Thank you. That's much easier.

Jerry


>Jerry,
>
>You don't need to jump through quite so many hoops, in fact your example loops through every row, and you said you only wanted the first row. Anyway, assuming you want it in a string (as in your example), you'd do this:
>
>string myvar = ds.Tables["mytable"].Rows[0]["myfield"].ToString();
>// -or-
>string myvar = (string)ds.Tables["mytable"].Rows[0]["myfield"];
>
>
>~~Bonnie
>
>
>>Using .Net 2003, how can I easily read the first row of a DataSet?
>>
>>Here's how I currently read the first row in a DataSet. This works, but I assume there is a better way.
>>
>>//ds contains my DataSet.
>>string myvar = "";
>>DataTable dt = ds.Tables["mytable"];
>>foreach (DataRow DRow in dt.Rows)
>>{
>>myvar = DRow["myfield"].ToString();
>>}
>>
>>Thanks,
>>
>>Jerry
Previous
Reply
Map
View

Click here to load this message in the networking platform