6 Replies Latest reply on Apr 18, 2011 12:00 PM by andreas

    Create a web application to access data through AF


      I am new to web coding so please forgive if I have made any fundamental mistakes here!


      I am trying to create a Web application to display PI data (without uwing Sharepoint and WebParts). At the moment, I have a simple 'Hello World' ASP .NET Web Application, built in Visual Studio 2008, that has a label which is filled in in the Page_Load event handler.


      To start off, I wanted to connect to our AF Server and display its DB name, then work towards getting eement and attribute data etc. So here is my code:


      using System;
      using System.Collections;
      using System.Configuration;
      using System.Data;
      using System.Linq;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.HtmlControls;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Xml.Linq;
      using OSIsoft.AF;
      namespace PIWebApp
          public partial class _Default : System.Web.UI.Page
              PISystems af ;
              PISystem mySystem;
              AFDatabase myDatabase;
              protected void Page_Load(object sender, EventArgs e)
                  af = new PISystems();
                  mySystem = af["LIMES"]; //TODO: Must change to your AF server
                  myDatabase = mySystem.Databases["Configuration"]; //TODO: Must change to your AF database
                  Label1.Text = "Hello World. My AF DB is called " + myDatabase.Name;



      The AF-related code is lifted directly from a Windows .NET application that works. But when I run this, it fails.'af' is initialised ok and so is 'mySystem', but its 'Databases' collection contains no objects and assigning myDatabase to "Configuration" brings up a dialog looking for PISystem.cs.


      Any ideas?


      --- Alistair.