Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error adding object (document)

Status
Not open for further replies.

psmello

Programmer
May 14, 2003
10
US
I get an error each time I use the AddDocument function in the LAPI. The error is a memory error on one machine and the app just bombs with no error on another machine. I've tried different files (TXT & TIFF), but the same error occurs. The doc does get created, but not without the error.

Also, I've tried to use the CreateObjectEx function and get the same problem. But this function does not create the document. I've tried to add to the root of the Enterprise Workspace as well as other sub-folders. Same problem.

What am I missing? Does anyone have an example? Here's the function I created:

Public Function Create_LLDoc(ByVal lParentID As Long, ByVal sName As String, ByVal lType As Long, ByVal sPath As String) As String

Dim status As Long
Dim NodeID As Long
Dim nodeVol As Long
Dim lObjInfo As Long

' Add document
'status = LL_AddDocument(session, parentVol, lParentID, sName, sPath, ObjInfo, 0)
status = LL_CreateObjectEx(session, parentVol, lParentID, LL_OBJECTTYPE, lType, sName, 1, lObjInfo)

If (status = LL_OK) Then
status = LL_AssocGetInteger(ObjInfo, "ID", NodeID)
End If

status = LL_CreateVersion(session, parentVol, NodeID, sPath, 1)

If (status = LL_OK) Then
CreateLLDoc = CStr(NodeID)
Else
CreateLLDoc = ""
End If

End Function

Thanks!
 
If the document gets created with the error can you not get the error back from lapi since LAPI has error handling.If the error is not lapi and windows are you using a well defined port to do this some ports are designed for specific services.Anyways after you install lapi on the windows machine which I presume has the livelink software also run your sample from another windows machine by copying only the lapi files and compiling on that machine and see if you can replicate it.I have done some lapi experimentation with java and it has worked for me very well and most of windows problems may be resolved by re-installing the winsock dll
Also VBsamples are in the knowledge base.
 
Thanks. I've tried the app on several machines and against two different Livelink server. In all cases, Windows hoses the app. No error is returned from the LAPI. I've used the LAPI with port 2099, and HTTPS with both the ISAPI DLL and LIVELINK.EXE via port 80. Could this be a LAPI DLL version issue?
 
Maybe this is a version issue and you should try the opentext knowledge base LAPI discussion.I'm a novice when it comes to https and VB.Sorry cannot help you there.
 
You need to alocate all the variables that you pass to the function before you use them. You then need to deallocate afterwards. LAPI functions do not pass variables, they pass long pointers to allocated memory.

Sample here. This function adds a new doc or does an Add Version if "name" exists. Below is the GetNodeID function that it uses as well. I used have a LAPI based function for GetNodeID but it was too slow and I used it a lot, so I cheat and use SQL! "Log" and "SafeSQLString" are other misc function I have in my libraries, but you can delete these lines if you don't have similar.

Function Livelink_DocumentAdd(ByVal lngParentId As Long, ByVal Name As String, ByVal file As String) As Long 'load a document from file into node and call it name
Dim ReturnStatus As Long
Log "Loading into Node: " & lngParentId, 3
status = LL_ValueAlloc(tmpAttribs)
status = LL_ValueAlloc(tmpCreate)
status = LL_ValueAlloc(tmpObject2)
status = LL_ValueAlloc(tmpObject)
status = LL_ValueAlloc(tmpVersion)
tmpDocNodeID = GetNodeID(lngParentId, Name)
If tmpDocNodeID = 0 Then
Log "Create New : " & Name, 3
ReturnStatus = LL_AddDocument(lngSession, lngVolumeID, lngParentId, Name, file, tmpObject2, tmpVersion)
Else
Log "Add Version : " & Name, 3
ReturnStatus = LL_CreateVersion(lngSession, lngVolumeID, tmpDocNodeID, file, tmpObject2)
End If
status = LL_ValueFree(tmpAttribs)
status = LL_ValueFree(tmpObject)
status = LL_ValueFree(tmpObject2)
status = LL_ValueFree(tmpVersion)
status = LL_ValueFree(tmpCreate)
Livelink_DocumentAdd = ReturnStatus
End Function

Function GetNodeID(ByVal lngParent As Long, ByVal strChild As String) As Long
'returns the node ID of a child of lngParent called strChild
'This function gets the ID direct from the database. It is much quicker than looping through the
'child nodes via LAPI.
Dim lngID As Long
Dim strSQLStatement As String
Dim rsParentNode As ADODB.Recordset
strChild = SafeSQLString(strChild)
strSQL = "SELECT dataid FROM dtree WHERE name = '" & strChild & "' AND parentid = " & lngParent
Set rsLL = objLLConn.Execute(strSQL)
If rsLL.EOF Then
GetNodeID = 0
Else
GetNodeID = rsLL!dataid
End If
End Function


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top