2 Replies Latest reply on Jan 5, 2017 7:59 AM by saifulazmi

    AF SDK: existing data keep updating when inserting a new data into AFTable


      I am having an issue to insert a new data into AF Table (using AF SDK) as it keep updating the existing data in table as result only on row available in table. Here my code and appreciate if anyone can advise any issue on this code:


      Dim dtMyTable As New DataTable()
      Dim drMyRow As DataRow = dtMyTable.NewRow()
      Dim piSystem As PISystem = piSystems.DefaultPISystem
      Dim AFPIPoint As PIPoint = Nothing
      Dim netcredentional As New NetworkCredential(strSQLUser, strSQLPassword)
      Dim afDatabase As AFDatabase = piSystem.Databases(strSQLDatabase)
      Dim myTable As AFTable = Nothing
      dtMyTable.Columns.Add("ID", GetType(Integer))
      dtMyTable.Columns.Add("Region", GetType(String))
      dtMyTable.Columns.Add("Site", GetType(String))
      dtMyTable.Columns.Add("Facilities", GetType(String))
      dtMyTable.Columns.Add("EquipmentType", GetType(String))
      dtMyTable.Columns.Add("EquipmentName", GetType(String))
      dtMyTable.Columns.Add("Unit", GetType(String))
      dtMyTable.Columns.Add("unitvalue", GetType(String))
      dtMyTable.Columns.Add("TriggerDate", GetType(Date))
       drMyRow.Item("ID") = pkID + 1 ' add as new id 
       drMyRow.Item("Region") = objRegion '
       drMyRow.Item("Site") = objSite
       drMyRow.Item("Facilities") = objFacilities
       drMyRow.Item("EquipmentType") = objEQType
       drMyRow.Item("EquipmentName") = objEQName
       drMyRow.Item("Unit") = objUnit
       drMyRow.Item("unitvalue") = objUnitValue
       drMyRow.Item("TriggerDate") = Date.Now
       myTable.Table = dtMyTable