Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Retrieving a field value from a Dataset
Message
De
25/07/2002 18:56:18
 
 
À
25/07/2002 01:16:10
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00682350
Message ID:
00682816
Vues:
21
I just realized that I had mis-typed the code example I had posted previously for type DataSets. Sorry guys. Here's the correct syntax:
   dsCustomers.Customers[0].cCustName.ToString();
Notice now that there is no mention of the Rows[] collection. Customers[0] is the first row in the table, Customers[1] is the next, and so on. The only thing that you use Rows for in this scenario is for a record count.
    MyCount = dsCustomers.Customers.Rows.Count;
Sorry about the typo -- I hope it didn't confuse anyone.

~~Bonnie

>Jorge,
>
>In addition to Cathi's reply, I'd like to add something and hope it doesn't further confuse you. Another option when using DataSets is to have .NET generate a typed dataset for you (right click in your .xsd and click on the Generate option). The syntax is easier to handle. Your example would then be:
>
>
>  dsCustomers.Customers.Rows[0].cCustName.ToString();
>
>
>A typed DataSet allows Intellisense to kick in for both your table names and your column names, which you don't get with just a regular DataSet. Also notice that I used a Rows[0], rather than [1]. Don't forget that the Rows collection is zero-based.
>
>~~Bonnie
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform