3 Replies Latest reply on Feb 19, 2013 4:28 AM by pcombellick

    'Received an invalid column length from the bcp client for colid xx' error when calling AFDatabase.ApplyChanges

    wxz44428

      We are coding against AF SDK 2.4, and trying to programatically creating UoM and Element templates. However, we ran into an issue, as described below.

       

      We are adding a list of ElementTemplates in a loop, by calling the following in the loop

       

      AfDatabase.AElementTemplates.Add(templateName);

       

      Then we add attributes to each of the ElementTemplate, after which, we will call

       

      AfDatabase.ApplyChanges() method. However, this call will fail with the following error:

       

      Timestamp: 2/18/2013 7:17:35 PM
      Message: Unexpected Server Error: 'SQL Error (4815) Received an invalid column length from the bcp client for colid 20.'.
      Use Event Viewer to see the AF service log file for more information. (157b9d26-2866-4746-9876-5c90f88df1f1)
      System.InvalidOperationException: Unexpected Server Error: 'SQL Error (4815) Received an invalid column length from the bcp client for colid 20.'.
      Use Event Viewer to see the AF service log file for more information.
         at OSIsoft.AF.Support.AFSerialProxy.ApplyChangesElementTemplate(dcElementTemplate[] changes, dcObjectIdentity[] deletedIdentities) in c:\Builds\AF\AF 2.4\Sources\SDK\Support\AFProxy.Remote.cs:line 3886
         at OSIsoft.AF.Asset.AFElementTemplate.RemoteApplyChangesElementTemplate(AFDatabase database, Boolean databaseCheckIn, dcElementTemplate[] changes, dcObjectIdentity[] deletedIdentities) in c:\Builds\AF\AF 2.4\Sources\SDK\Asset\AFElementTemplate.Remote.cs:line 128
         at OSIsoft.AF.AFDatabase.SaveElementTemplates(Boolean doCheckIn, Boolean mustApplyChangesForListCheckIn, Boolean disableObjectListCheckIn, IDictionary`2 processedItemsDict, List`1 appliedList, List`1& changeList, List`1& deleteList) in c:\Builds\AF\AF 2.4\Sources\SDK\AFDatabase.Remote.cs:line 1465
         at OSIsoft.AF.AFDatabase.ProcessDatabaseChanges(Boolean doCheckIn, AFCheckedOutMode mode, IEnumerable`1 objList, List`1 appliedList) in c:\Builds\AF\AF 2.4\Sources\SDK\AFDatabase.Remote.cs:line 875
         at OSIsoft.AF.AFDatabase.ProcessDatabaseChanges(Boolean doCheckIn, AFCheckedOutMode mode) in c:\Builds\AF\AF 2.4\Sources\SDK\AFDatabase.Remote.cs:line 504
         at OSIsoft.AF.AFDatabase.ApplyChanges(AFCheckedOutMode mode) in c:\Builds\AF\AF 2.4\Sources\SDK\AFDatabase.cs:line 915

       

      The same code base seems to work fine when running on a different AF server, but fails on this box. Anyone with any experience on this, facing similar errors before ?

       

      Someone seems to suggest that, since we are adding elementTemplates in bulk (we add the templates in loop first), then outside of the loop, we call applyChanges in one shot, there might be a seting somewhere in AF, that might limit the among of data to be send to AF for updating. Is that true, if there is, what would be that AF config setting ?

       

      We do not have a dev environment on this box, so making the troubleshooting a bit difficult. Any of your kind assistance will be highly appreciated.

       

      Thanks,

       

      Joe

       

       

       

       

       

       

       

       

       

       

        • Re: 'Received an invalid column length from the bcp client for colid xx' error when calling AFDatabase.ApplyChanges
          pcombellick

          Joe,

           

          This looks like it should be a call to Tech Support.  However, generally, it is not necessary to call ApplyChanges() after adding a single object as this causes a round trip to the AF Server.  Generally, for best performance, you should add a bunch of objects, then call AFDatabase.CheckIn( AFCheckoutMode ... ).  When calling AFDatabase.CheckIn() or AFDatabase.ApplyChanges(), the AFSDK will batch up to 200 objects of the same type when sending to the AF Server.  CheckIn() is generally perferred over ApplyChanges() + CheckIn().

           

          What is the version of the other AF Server?  Has this ever worked or is this a new failure?  Does it work from PISystem Explorer ?

           

          Regards,

           

          Paul

           

          AF Dev