Error HRESULT E_FAIL has been returned from a call to a COM component.

SUGGESTED

Good day,

I am trying to export data from my local sql DB in sage.

I am new to sage integration, so i have narrow knowledge on this subject matter.

When i inserting InsertInvoiceDetailSoftCols() i get an exception "Error HRESULT E_FAIL has been returned from a call to a COM component." at PORCP1detail9.Insert()

Please assist.

Code/////

public override void InsertInvoiceDetailSoftCols()
{
         //RCP DETAILS
          PORCP1detail1.RecordGenerate(false);

         PORCP1detail1.Fields.FieldByName("ITEMNO").SetValue(base.dsDetailSoftCols.Tables[0].Rows[base.counterDSC]["ITEMNO"].ToString(), true); // Item Number

         PORCP1detail1.Fields.FieldByName("PROCESSCMD").SetValue("1", false); // Process Command
         PORCP1detail1.Process();

         PORCP1detail1.Fields.FieldByName("ITEMDESC").SetValue(base.dsDetailSoftCols.Tables[0].Rows[base.counterDSC]["ITEMDESC"].ToString(), true); // ITEM DESCRIPTION
         PORCP1detail1.Fields.FieldByName("RQRECEIVED").SetValue(base.dsDetailSoftCols.Tables[0].Rows[base.counterDSC]["RQRECEIVED"].ToString(), true); // QUANTITY RECEIVED
         PORCP1detail1.Fields.FieldByName("UNITCOST").SetValue(base.dsDetailSoftCols.Tables[0].Rows[base.counterDSC]["UNITCOST"].ToString(), true); // UNIT COST
         PORCP1detail1.Fields.FieldByName("GLACEXPENS").SetValue(base.dsDetailSoftCols.Tables[0].Rows[base.counterDSC]["GLACEXPENS"].ToString(), true); // EXPENSE ACCOUNT
         PORCP1detail1.Fields.FieldByName("TAXCLASS1").SetValue(base.dsDetailSoftCols.Tables[0].Rows[base.counterDSC]["TAXCLASS1"], true); // TAX CLASS
          PORCP1detail1.Fields.FieldByName("PROCESSCMD").SetValue("1", false); // Process Command

        // ===================================
        // ADD HEADER ADDITIONAL FELDS
        // ===================================
        if (base.dsDetailSoftCols.Tables[0].Rows[base.counterDSC]["DETAILSOFTCOLS"].ToString() == "1")
       {
             for (int scCol = 0; scCol < dsDetailSoftCols.Tables[1].Columns.Count; scCol++)
            {   
                      //========================================================
                        // Assign each Optional Field Name and Value SEPERATELY
                     //========================================================
                       PORCP1detail3.RecordClear();
                       PORCP1detail9.RecordGenerate(false);
                       PORCP1detail9.Fields.FieldByName("OPTFIELD").SetValue(base.dsDetailSoftCols.Tables[1].Columns[scCol].ColumnName, false); // OPTIONAL FIELD NAME
                        PORCP1detail9.Read(false);
                       PORCP1detail9.Fields.FieldByName("VALIFTEXT").SetValue(base.dsDetailSoftCols.Tables[1].Rows[base.counterDSC][scCol].ToString(), false); // OPTIONAL FIELD VALUE
                       // Update each Optional Field Name and Value
                      PORCP1detail9.Insert();
           }
      }

          PORCP1detail1.Insert();
}