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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error opening ACCPACXAPILib.xapiSession in VB.NET 2

Status
Not open for further replies.

warrickvdb

Programmer
Oct 7, 2003
13
ZA
Hi

I receive an error when i try to open the 'ACCPACXAPILib.xapiSession' object in VB.Net web project.

My code is as follows:
Dim Session As ACCPACXAPILib.xapiSession
Session = New ACCPACXAPILib.xapiSession
Session.Open("ADMIN", "ADMIN", "RMICON", Now.Today, 0)

The code crashes on the last line of code and returns the following error:

Unspecified error
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Unspecified error

Source Error:


Line 92: Dim Session As ACCPACXAPILib.xapiSession
Line 93: Session = New ACCPACXAPILib.xapiSession
Line 94: Session.Open("ADMIN", "ADMIN", "RMICON", Now.Today, 0)
Line 95:
Line 96: ARCUSTOMER = Session.OpenView("AR0024", "AR")


Source File: c:\inetpub\ Line: 94

Stack Trace:


[COMException (0x80004005): Unspecified error]
ACCPACXAPILib.xapiSessionClass.Open(String UserIdentifier, String Password, String DataBase, DateTime SessionDate, Int32 Flags) +0
RMIWeb.ucContact.Page_Load(Object sender, EventArgs e) in c:\inetpub\ System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
 
Here is the syntax that I would use to create and Open a session object.

Code:
Dim Session As ACCPACXAPILib.xapiSession
  Set Session = CreateObject("ACCPAC.xapisession")
  Session.Open "ADMIN", "ADMIN", "RMICON", Date, 0

The 'Date' is the /VB6 'Date' function that will return a date in the format '10/08/2003' (your computer's short date). I am not sure what the .net 'Now.Today' will return so just make sure that a correct date value is being returned.


Thanks and Good Luck!

zemp
 
I have tried that and it unfortunately doesn't work in .Net.

Where does AccPac check to see that I am using the correct Username and Password?
Where does AccPac store the database Id (RMICON) that I am passing into the variable?

Perhaps the problem lies with that?

A post I read somewhere suggested that problems could be caused by the 'Plususer.ini' file being incorrect.

The only thing in my file is:
[options]
default macro=C:\Program Files\ACCPAC\MACROS\MACRO01.AVB
default macro type=VBA

 
From the information I have been able to find the xAPI is not yet compatible with VB.Net. We still need to use VB6. This information is suspect and based on some threads from the ACCPAC partner discission forums (ACCPAC website) using ACCPAC 5.0. I have not tested it myself or have I tried to use the ACCPAC xAPI with VB.Net. The key would be the a4wcomm.dll that houses the xAPI. If it hasn't changed then the information may be true. If I am incorrect I hope someone will set the record straight. I am looking into it further.

You can check the database ID that you need to use by opening ACCPAC and Checking the 'Database ID' in Common services/company profile. Also double check the user name and password.

The xAPI uses the system manager to connect to the ACCPAC data. If the system manager can get in then usually the xAPI can.

Thanks and Good Luck!

zemp
 
Can't quite get it to work in VB .NET web project but
I just quickly tried the following code in a VB .NET Windows Application project:

Dim session As New ACCPACXAPILib.xapiSession()
session.Open("ADMIN", "ADMIN", "SAMINC", Now.Today, 0)
MsgBox(session.Company.Name)

I've got my "Sample Company Inc." in a message box without a problem.
I added a reference to XAPI library through Project -> Add Reference -> COM -> ACCPACXAPI 1.1 Type Library prior to start coding.

------------------------
rvspy@nospam.hotmai1.com
(remove nospam and change 1 to L)
 
Thanks for the replies. They have helped alot.

I have been trying to do this with version 5.1A, Has annybody tried this with version 6, or know if it is posisble?
 
Well here is my question and the response form the other forum. From a very reputable poster.

Q: Is the ACCPAC xAPI 1.1 Type Library (a4wcomm.dll)compatible with VB.Net or must we stay with VB6?

A: No, it's not. ACCPAC 5.1 service pack 2 or later got its own .NET libraries...

Thanks and Good Luck!

zemp
 
VB .NET is COM compatible which means you can still use it without the ACCPAC native .NET library, although VBA and VB6 would still be my tools of choice.
BTW, Zemp what this "other" forum? Are you referring to a certain JC person?

------------------------
rvspy@nospam.hotmai1.com
(remove nospam and change 1 to L)
 
VB .NET is COM compatible which means you can still use it without the ACCPAC native .NET library, although VBA and VB6 would still be my tools of choice.
BTW, Zemp what this "other" forum? Are you referring to a certain JC person?

Thanks everyone! I am learning new things from this forum everytime I visit.

------------------------
rvspy@nospam.hotmai1.com
(remove nospam and change 1 to L)
 
rvspy, as mentioned in my second post ("...threads from the ACCPAC partner discission forums...") the other forum was the ACCPAC partner discussion forum. No, it was not JC.

Glad to hear you are enjoying the forum(s). I learn somthing new every day as well.

Thanks and Good Luck!

zemp
 
I had a simmilar problem that i solve using two extra line just before de session.close()

System.GC.Collect()
System.GC.WaitForPendingFinalizers()

i guest that you need to force the Garbage collector to complete the destroy of the views...

That works for me , hope this help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top