on 05-08-2006 6:04 AM
the Process once I have connected with the company is to first check existance of a UDF in the ORDR table
if it is not there I call the following function
using
createUDF("U_UpldDte", "Upload Flag", "ORDR")
but it always fails with :
Ref count for this object is higher then 0
I have tried using the
UserFields object and the UserFieldsMD but with no success,
The Ocompany object is global,
releasing the object prior to use does not help.
The frustrating thing is that I have met this problem b4 and was able to get past it but due to a hard drive failure (dont ask!!! ) I lost that particular piece of code...
Public Shared Function createUDF(ByVal UDFName As String, ByVal UDFDescription As String, ByVal UDFTable As String) As String
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim ErrorMsg As String
Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
Try
oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
GC.Collect()
oUserFieldsMD = Nothing
oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
With oUserFieldsMD
.TableName = UDFTable
.Description = UDFDescription
.Name = UDFName
.Type = SAPbobsCOM.BoFieldTypes.db_Alpha
.EditSize = 10
End With
RetVal = oUserFieldsMD.Add
If RetVal <> 0 Then
oCompany.GetLastError(ErrCode, ErrMsg)
ErrorMsg = ErrCode & " " & ErrMsg
End If
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
oUserFieldsMD = Nothing
GC.Collect()
Catch ex As Exception
createUDF = "ERROR: Unable to create " + UDFName + " In " + UDFTable + ex.Message
Exit Function
End Try
End Function
Hi George Savery
The reason it is doing this is because you have more than one meta data object active. You must use UserFieldsMD, the md stands for meta data. Before calling this procedure you must have no other meta data objects open that have not been released. In your code here, at the bottom you release the object, perfect. But do you have any others you have not done this to??? Is there a recordset that you used before calling this??? If so, close it.
Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
spot On Louis.
I used an
oOrders = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
to use when looking to see if the UserField existed when I added the lines
System.Runtime.InteropServices.Marshal.ReleaseComObject(oOrders)
oOrders = Nothing
GC.Collect()
the Error dissappeared.
(pls excuse the 'verbosenes' as I dont want to spend another day trying to figure this out
Thanks Again!!!!
User | Count |
---|---|
96 | |
10 | |
9 | |
6 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.