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