Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return DataSet From DataSet
Message
From
18/07/2010 12:04:08
 
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01472665
Message ID:
01472861
Views:
48
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform