6 Replies Latest reply on Aug 31, 2010 3:37 PM by spilon

    Missing "value" field

    Kenneth.Rice

      Hi everyone,

       

      I decided I would join the "dark" side and learn to create web services and .aspx pages (last programming days were in College).

       

      Heres the problem I borrowed the "Building a Web Service that Executes PI SQL and Returns a Data Set". Web Service running well, now I made a aspx page with a gridview object, 4 text boxes and a button.

       

      I submit the query

       

      SELECT "tag", "time", "value", "status", "questionable", "substituted", "annotated", "annotations" FROM "piarchive".."pisnapshot" WHERE tag = 'sinusoid'

       

      Everything returns to the gridview except the value field. What am I missing/doing wrong?

       

      Thanks in advance

        • Re: Missing "value" field
          smohr

          Value on the wire is the textual content of the TimedValue element, whereas everything else is an attribute.  For example:

           

           

           

                      <TimeSeries Error="0" Path="pi:\\philly\sinusoid" DataType="Double" UOM="Hz">
                         <TimedValues>
                            <TimedValue Time="2010-08-30T17:38:58Z">88.0106506347656</TimedValue>
                            <TimedValue Time="2010-08-30T18:00:58Z">93.5104598999023</TimedValue>
                         </TimedValues>
                      </TimeSeries>

           

          This gives some clients a problem.  InfoPath, for example, wants to turn every TimedValue into a bulleted entry unless you delete TimedValue from TimeSeries and enter it by itself.  You may have to poke around in the grid binding to make sure that you pick up the value.

            • Re: Missing "value" field
              Kenneth.Rice

              Stephen,

               

              Thank you very much, I had to ask a "real" developer what you meant LOL, but he was able to translate to me that "I have a lot to learn".

               

              Now I remember why I gravitated toward Application/System Administration its so nice to tell a "programmer" I think you have a bug vs. understanding all the different ways items get returned to you and how to handle each correctly.

               

               

               

              thanks again

                • Re: Missing "value" field

                  @Kenneth Rice: I am under the impression that Stephen may have misinterpreted your original post, and replied with something pertaining with the PI Web Services product.

                   

                  I am not in a position where I can test what you are doing specificially, but I'm thinking it might have to do with the fact the Value field in the PIArchive.PISnapshot table is of type variant, and the DataGrid has trouble interpreting what it being returned. Does it show the column at all (i.e. with no value in it), or the grid just doesn't show a column for it? Can you try and convert this column as a string?

                  SELECT "tag", "time", CAST(value AS string), "status", "questionable", "substituted", "annotated", "annotations" FROM "piarchive".."pisnapshot" WHERE tag = 'sinusoid'
                    • Re: Missing "value" field
                      Kenneth.Rice

                      @Steve: I will let the "experts" debate weather Stephen was answering based on PI Web Services, or the PI-OLEDB web service. My coleague said that basically he thought Stephen meant that the value was being returned as an object that the gridview didnt know how to "CAST" or interupt and that he would somehow loop through the returned dataset and cast the value field to a double or string or ...?

                       

                      So Stephen answer did lead us to understand more about the situation, I had just changed the query to picomp2 and did '*' as the time and that gave me the value field.

                       

                      Did not think to CAST Value in the SQL Statement itself . Did I mention my programming days date back to college . Thank You all for your patience, maybe some day my questions will take more than 5 seconds to fix.

                       

                      BTW Steve CAST ing Value as String fixes the issue.

                       

                      Would you care to tell me why CAST when I select from pisnapshot is needed but is not if I select from picomp2?

                       

                      Thanks again

                        • Re: Missing "value" field
                          smohr

                          I just want to clarify that I was speaking in terms of PI Web Services 2010, not PI-OLEDB.  I'm sorry that caused some confusion. On the other hand, it sounds like you learned more about the latter, which is always good.  Again, I hope I didn't take you too far astray.

                          • Re: Missing "value" field

                            Kenneth Rice

                            I will let the "experts" debate weather Stephen was answering based on PI Web Services, or the PI-OLEDB web service.
                            As you can see, Stephen confirmed he was indeed talking about PI Web Services - what led me to believe this is how he referenced the TimeSeries and TimedValue objects (2 classes/types from the PI Web Services definition).

                             

                            Kenneth Rice

                            BTW Steve CAST ing Value as String fixes the issue.
                            Good, glad that helped!

                             

                            Kenneth Rice

                            Thank You all for your patience, maybe some day my questions will take more than 5 seconds to fix.
                            No worries, that's why we're here! And we all need to start somewhere

                             

                            Kenneth Rice

                            Would you care to tell me why CAST when I select from pisnapshot is needed but is not if I select from picomp2?
                            In fact the variant returned by the Value column in PISnapshot is not really different than the one returned in the PIComp2 table. My suspicion is that it has to do with the actual data that's being returned for the specified Time Range - and the fact that your data grid may be a little picky on data types.

                             

                            My experience with the DataGrid showed that's it's usually pretty good at showing 'anything' - it would interpret variants/objects and get their string representation to show them. Somehow the DataGrid object you are using may be a little more picky, so transforming ambiguous fields into text strings definitely helps.