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!

How can I close Accpac xapiSession?

Status
Not open for further replies.

ygl

Programmer
Jan 18, 2007
10
US
In my VB .NET code I use the following code:
Dim glSession As ACCPACXAPILib.IxapiSession
...
glSession = New ACCPACXAPILib.xapiSession
...
glSession(i).Open("ADMIN", "ADMIN", accpacDbName, Now, 0)

I tried to do the following to close the above session:
glSession.Close()
I get the following error:
Run-time exception thrown : System.Runtime.InteropServices.COMException - Unspecified error

Does anybody know why am I getting "Uspecified error", what is it and how can I close the session to destroy ACCPAC object?
 
As an aside - why are you using the XAPI vs. the COMAPI interface?

At first glance (and I'm not a .NET developer) this line looks funny:

glSession(i).Open("ADMIN", "ADMIN", accpacDbName, Now, 0)

Do you have an array of glSessions?

In VBA you might simply need to assign your variable to nothing to close it:

set glSession = Nothing

Regards,

Django

 
Assigning a variable to nothing to close it works in VBA, but in .NET it only clears the association of the varible with the object. The object(Accpac session) still exists.
By hte way in my code I process an arrray of sessions, i.e. handle multiple companies in a loop.
 
Should you not be using glSession(i).Close() and close each session in the array?
I don't think glSession.Close() will work.
Also setup an error jandler to get the returned errors, it may give you the unspecified error.
 
I am already doing it. I may have confused you since I wanted to include a simple code snipplet by not showing that I have an array of sessions and apparently I missed one. I also have error handling set-up and have captured "Unspecified error" message, which doesn't tell me much.
Below is my actual code:
Dim glSession() As ACCPACXAPILib.IxapiSession
Dim glName() As Boolean
Dim i As Integer
...
Try
...
If Not glName(i) Then
glSession(i) = New ACCPACXAPILib.xapiSession
...
glSession(i).Open("ADMIN", "ADMIN", accpacDbName, Now, 0)
glName(i) = True
End If
...
Catch ex As Exception
...
Finally
For i = 0 To glCompanyCount 'close all opened Accpac sessions
If glName(i) Then 'indicates that session was opened
glSession(i).Close() 'this is where I'm getting "unspecified error" message
End If
Next i
...
End Try
 
I can only go by what you typed in your post, and that did not include (i) on the .Close.

Anyway, have you tried a test where glSession is not an array?

Are you opening any Accpac views? If so then these need to be closed before you close the session.
 
I am opening Accpac views. Let me try to implicitly close them.
Thanks.
 
Do you know how to close a view? There is no "Close" method for this object.
 
There is in the COMAPI, I think you are missing out on a lot by using the xAPI.
 
Does anybody know where I can found documentaion on Accpac COMAPI?
 
Does any body know how to deal with views in Accpac comAPI?
I need to create batch, header and detail views in order to insert information in Accpac GL databases.
I did this in xAPi but based on intellesense of VB .NET the properties and methods of comAPI differ from xAPI.
I don't have any documentation on comAPI.
Any ideas are welcome.
Thanks.
 
Record a macro in Accpac and you'll have all the code you need.

Jay Converse
IT Director
Systemlink, Inc.
 
I though the recording macro gives you xAPI code, which I already have. By browsing comMapi object through my VB .NET program I see that it has different methods than xAPI. FGor example, I use "OpenView" method for a view in xAPI, but there is nothing like this in comAPI.
 
What version of Accpac are you running? Anything 5.2 or later gives you COMAPI code.

Jay Converse
IT Director
Systemlink, Inc.
 
Finally, now we understand.

I'm not going to touch any XAPI development in 5.0, that's a obsolete product.

Jay Converse
IT Director
Systemlink, Inc.
 
The problem was that we had existing MS ACCESS VBA code developed way prior to Accpac 5.0. Some basic code was generated at that time by using macro generated code which was xAPI syntax.
Now that I'm trying to convert this logic into VB .NET and our version of Accpac is higher it is possible that the newly generated macro code will be in comAPI format.
Let me try to create macro VBA now in 5.0 and see if it gives me comAPI syntax.

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top