Skip to Content
0
Former Member
Jan 07, 2010 at 05:41 AM

Table creation Error "Ref Count for this object is higher than 0"

137 Views

Hi All

I have a problem in creation of table using SDK on a button event. I have a procedure to create tables and fields. If I call this procedure on a menu Event than it works fine but If I call this procedure on a button event than It gives error "Ref count for this object is higher than 0" . I know this error occur When an object does not release after creating a table. but this error occur at when first table is created. My code it given below. plz see and give me your valuable suggestions.

Dim oUserTablesMD As SAPbobsCOM.UserTablesMD

Try

oUserTablesMD = B1Connections.diCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)

oUserTablesMD.TableName = "AM_OBIN"

oUserTablesMD.TableDescription = "PutAway Table"

oUserTablesMD.TableType = BoUTBTableType.bott_Document

lRetCode = oUserTablesMD.Add

'// check for errors in the process

If lRetCode <> 0 Then

B1Connections.diCompany.GetLastError(lRetCode, sErrMsg)

MsgBox(sErrMsg)

Else

B1Connections.theAppl.StatusBar.SetText("Table: " & oUserTablesMD.TableName & " was added successfully", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success)

End If

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

oUserTablesMD = Nothing

GC.Collect()

'***************************************************************

oUserTablesMD = B1Connections.diCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)

oUserTablesMD.TableName = "AM_BIN1"

oUserTablesMD.TableDescription = "PutAway Upper Grid"

oUserTablesMD.TableType = BoUTBTableType.bott_DocumentLines

lRetCode = oUserTablesMD.Add

'// check for errors in the process

If lRetCode <> 0 Then

If lRetCode = -1 Then

Else

B1Connections.diCompany.GetLastError(lRetCode, sErrMsg)

MsgBox(sErrMsg)

End If

Else

B1Connections.theAppl.StatusBar.SetText("Table: " & oUserTablesMD.TableName & " was added successfully", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success)

End If

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

oUserTablesMD = Nothing

GC.Collect()

Catch ex As Exception

MsgBox(ex.Message)

End Try

Thanks

Regards

Gorge