Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading a row in a DataSet
Message
De
19/09/2003 08:05:31
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
 
 
À
18/09/2003 17:17:19
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00830470
Message ID:
00830613
Vues:
23
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform