Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return DataSet From DataSet
Message
De
18/07/2010 12:04:08
 
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Divers
Thread ID:
01472665
Message ID:
01472861
Vues:
49
>This fails with the exception "The source contains no data rows" if no rows were found that match the criteria:
>
>
>DataTable Products = csCOSApp.ActiveProject.dsDataStore.Tables[0].Select("ProductId > 0").CopyToDataTable();
>
>
>Any thoughts on why? Shouldn't I just get back an empty table?


You'd think it would work that way, wouldn't you? Oh well ... you can use the CopyToDataTable() method with a slightly different signature that will get around the problem:
// Your DataTable has to already exist
DataTable Products = new DataTable();
csCOSApp.ActiveProject.dsDataStore.Tables[0].Select("ProductId > 0").CopyToDataTable(Products, LoadOption.PreserveChanges, delegate{});
The anonymous delegate is the exception handler, and since you really don't need it to do anything, it can be an empty method.

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

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

Click here to load this message in the networking platform