Problem using Expression in DataTable.Select method, help me, please. RRS feed

  • Question

  • Hi


    Since my question was not popular as being labelled «Null reference exception thrown when using Expression in DataTable.Select method» I renamed it. I hope to get some answers to this problem. :-)


    I am having a weird problem here. First, I'm using .Net 1.1, C#.

    In my application, I am reading configuration information from an Xml file.

    Here is a sample of something that looks like my xml file :

    <?xml version="1.0" ?>


    <TopItem id="0" category="ABC">

    <ItemABC name="myNameIsAAA" category="abc" />

    <ItemABC name="myNameIsBBB" category="abc" />

    <ItemABC name="myNameIsCCC" category="ttt" />


    <TopItem id="1" category="XYZ">

    <ItemABC name="myNameIsAAA" category="xyz" />

    <ItemABC name="myNameIsBBB" category="abc" />

    <ItemABC name="myNameIsHHH" category="xyz" />





    I want to get the ItemABCRows when category is xyz AND the parent's category

    (In other words, TopItem's category) is XYZ. 


    So I was thinking that the following would work, right ?


    MyDataSet.ItemABCRow[]  myRowsABC = "Parent.category='XYZ' AND category='xyz' ") as MyDataSet.ItemABCRow[];


    But it is not working, I'm getting an "Unhandled exception of type SystemNullReferenceException in occured. Additional info :  object not set to an instance of an object".


    Is this a known bug of .Net 1.1 ? is there a way around it ? I would not want to loop through my TopItem rows to get to the second level...


    Thanks in advance!




    Isabelle A.M.

    Please respond to this newsgroups so others can beneficiate of the answer(s) as well.

    Friday, September 14, 2007 5:43 PM

All replies

  • and i still don't have an answer to this. If I find it by myself, I will post an answer.


    Monday, September 17, 2007 4:18 PM
  • Hi,


    I think your problem is your using an expression statement (Parent.category) in the select statement, I don't think this is possible, or at least I haven't see it get used. The Parent.Category expression statement would be used to create an expression column in your ItemABC table, it would pull the parents category down into the child column. In which case you could then use the select statement like this, assume the expression column is called PCategory...


     ... "PCategory='XYZ' AND category='xyz' ")


    Does that fix your problem?

    Monday, September 17, 2007 6:30 PM