Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
IEnumerable<datarow> query1 = from myRow in result.Tables["Sheet1"].AsEnumerable()
                              where myRow.Field<string>("Action") == "AddFixedPriceItem"
                              select myRow;


When I trying to upload the excel sheeet "Sheet1" I got the exception .
Posted
v4

1 solution

Something here is null when you are using its methods / paramters:


C#
if(result==null)
 throw new Exception("There's your problem");
if(result.Tables==null)
 throw new Exception("There's your problem");
if(result.Tables["Sheet1"]==null)
 throw new Exception("There's your problem");

IEnumerable query1 = from myRow in result.Tables["Sheet1"].AsEnumerable()
where myRow.Field("Action") == "AddFixedPriceItem"


potentially myRow could be null, but I doubt it. myRow.Field("Action") could absolutely be null but you are not trying to access its properties so it won't cause the error
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900