DataView

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • web1110

    DataView

    This is a rehash of a response question I made down below.

    I am playing with the NorthWind database. I have created a DataSet and
    loaded the Employees table into it. I have created a DataView on that
    table.

    Now, I am having trouble putting all the parts together to retrieve a single
    row of that DataView. For instance, if I want to retrieve the row where
    EmployeeId='2' and display the FirstName of that employee, what steps do I
    need to perform? What I've tried keeps getting syntax errors or exceptions.

    For instance, both

    dataView1.RowFi lter="EmployeeI d != '2'";
    dataView1.RowFi lter="EmployeeI d != 2"; // No single quotes

    Gives me the error:

    Cannot interpret token '!' at position 12.

    Since the filter removes the rows that match the contition, I have to
    negate the condition to get the data I want.

    I'd appreciate some help.

    Thanx,
    Bill


  • Cor Ligthert

    #2
    Re: DataView

    Bill,

    Why would it be != when = is the equal operator and not ==.

    The unequal operator is <>


    I hope this helps,

    Cor



    Comment

    • web1110

      #3
      Re: DataView

      Thanks again. Mind is on other things I guess. Anyway, additional details
      on the steps would be very helpful.


      Comment

      • web1110

        #4
        Re: DataView


        As I play with this, I find that a table automatically has a defaultview
        that can be used. Therefore, using a DataView does not appear to be
        necessary. I think I am I making progress here.


        Comment

        • Cor Ligthert

          #5
          Re: DataView

          Bill,

          You mean
          dataView1.RowFi lter = "EmployeeId='2' "
          string MyFirstName = dataView1.Item[0]["FirstName"];


          Cor


          Comment

          • Cor Ligthert

            #6
            Re: DataView

            Right,


            Comment

            • web1110

              #7
              Re: DataView

              That's it. It was too simple to figure out except Item wasn't recognzed.
              Had to use:

              string MyFirstName=dat aView1[0]["FirstName"].ToString();

              Thank you much,
              Bill



              Comment

              Working...