Skip to Content
0
Former Member
Dec 29, 2005 at 01:48 PM

Cannot remove user define fields

37 Views

Hi,

I am trying to remove a user defined field (U_Prirev) in Table (OHEM) and am getting the following error:

Ref count for this object in higher then 0. Error No -1120

The code is as follows :

Dim sRequete As String

Dim errCode As Long

Dim errMsg As String

Dim IdField As Integer

Dim oUFields As SAPbobsCOM.UserFieldsMD

oUFields = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)

Dim oRecordSet As SAPbobsCOM.Recordset

oRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

sRequete = "SELECT FieldID FROM CUFD where TableId = '" & pNomTable & _

"' and AliasID = '" & pNomChamp & "'"

oRecordSet.DoQuery(sRequete)

If (oRecordSet.EoF = False) Then

IdField = CType(oRecordSet.Fields.Item(0).Value, Integer))

If (oUFields.GetByKey(pNomTable, IdField) = True) Then

If (oUFields.Remove() <> 0) Then

oCompany.GetLastError(errCode, errMsg)

Console.WriteLine("Erreur => Code = " & errCode.ToString + " Message = " + errMsg)

End If

End If

End If

System.Runtime.InteropServices.Marshal.ReleaseComObject(oUFields)

oRecordSet = Nothing

End Sub

Anyone knows why i am getting this error.

Thanks

Laurent.