Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


xAPI Session.Open problem

xAPI Session.Open problem

xAPI Session.Open problem

In VB6 IDE the following code produces this error:
"Error when opening database link"

The code:
   Dim oSess As xapiSession
    Set oSess = CreateObject("ACCPAC.xapiSession")
    oSess.Open [USERID], [PW], [DATABASE], [DATE],0

Any help would be greatly appreciated.

RE: xAPI Session.Open problem

Hello Aceger

Your Question:
In VB6 IDE the following code produces this error:
"Error when opening database link"

The code:
   Dim oSess As xapiSession
    Set oSess = CreateObject("ACCPAC.xapiSession")
    oSess.Open [USERID], [PW], [DATABASE], [DATE],0

Any help would be greatly appreciated.

My answer :
Firstly :
If you using VB6 then you need to set a reference to the ACCPACXAPILIB 1.1. You do this by going to Project/References and then select ACCPACXAPILIB 1.1.

After youve dont that, you must change your code to look like this :

Dim OSess as AccPacXApilib.xapisession

In normal AccPac VBA you dont have to reference that AccPacXApilib you can just type Dim Osess as xapisession like you have it in your question

Secondly, your Session OPEN method syntax is
OSess.open "USERID","PASSWORD","ORGID",date,o

2.1 Make sure it is strings and not in [] blocking
2.2 Make sure all is case sensitive
2.3 Make sure your ORGID is the exact name of the "COMPANY" like you have specified it when you created it.

Hope it helps :)


RE: xAPI Session.Open problem

Hi, I've been having the same probelm for a couple weeks now and I can't figure it out. I did everything UC27 sepecified but it still gives that same error, "Error when opening database link". If you figured thos out Aceger I would really appreciate it if you could let me know what you did.

RE: xAPI Session.Open problem

Hello everyone!
Strangely,  after 2 weeks of struggling I solved the problem an hour after I made this post. I was about to throw myself out the window. For those who find themselves in this dilemma here is what I did...
I did exactly what UC27 said, that part was right. The probelm was with where I ran my Vb app from. In the help files in accpac it has a little note saying "make sure the ACCPAC runtime directory is in the path or the VBA hosting program starts in the ACCPAC runtime directory". I did just that, I ran my application from the accpac\runtime\ directory and it worked A-ok. So try that if you find yourself in the same situation as I did.
good day to you all

RE: xAPI Session.Open problem

Hello Jaycee,

Nice to see you here. I was goiing to send this to you and suggest you help.


RE: xAPI Session.Open problem


I tried everything in the post, and eventually found another problem.  There is a file called Plususer.ini in the Users folder.  If the path in there to the database you are looking for is wrong, you get the same error message.

I changed the path, and my app worked fine.  For a few seconds that is, and then the paths change back to the defaults - my app breaks again.  Does anyone know why:

 - the paths in Plususer.ini change
 - how to override those paths in code


RE: xAPI Session.Open problem

I am not sure if you are confused by the wording of a post in this thread.

Wredd23's post contained:   "make sure the ACCPAC runtime directory is in the path"

The 'path' that is being refered to in the help files is the OS search path in the Autoexec.bat file. If you include the accpac runtime directory in that search path then your app can find the A4WCOMM.dll that the xAPI runs from (by default it is placed in the accpac runtime folder). Another way to resolve this would be to place a copy of the A4WCOM.dll file into the windows system or windows system32 folder. These folders are already included in the default search path in the autoexec.bat file. This way you can run your xAPI apps from anywhere on your computer.

The xAPI is just a hook into Accpac. It is just a way to communicate with the accpac data without opening the accpac interface. If the accpac interface can see your data in the folders found in your Plususer.ini file then the xAPI will as well.

Thanks and Good Luck!


RE: xAPI Session.Open problem

Hi zemp,

Thanks for the reply.  I am running AccPac on a Win2000 machine, so I put all the relevant paths in the Environment tables (which is equivalent to the Autoexec.bat).  I am also running the test app in the runtime folder.  

The first time I ran AccPac, it said it also could not find the paths, and requested me to browse to the data folders which I did.  Thereafter it works fine, but my app won't work at all.  I have gone through just about every setting on the machine looking for the link between the database location and the path that is in Plususer.ini, but still have had no joy.

The machine was initially set up as a server, and the path that is in there is the mapped path that clients on the network use to access ACCPAC.  I am running AccPac directly on that machine now, and am not using a mapped drive.  

My next steps, which I haven't had a chance to test are:
1. Try to get a mapped drive working (to the local file location of the data files)
2. Try running the app from a different machine.

The problem is not finding xAPI, the problem is finding the database files.


RE: xAPI Session.Open problem

A couple of things to check. When you are setting up your data are you doing through the AccPac database setup? If not you may need to go there and verify your data or set up the data again. Accpac is a complicated program, it is not wise to change any files it creates (Plususer.ini). Better to have Accpac recreate it.

Is system manager installed locally on the machine? Probably is but just checking because it is a must for the xAPI.

If your company and its data are setup properly in AccPac you should not have any major problems connecting with the xAPI.

Thanks and Good Luck!


RE: xAPI Session.Open problem

i think i facing the problem when open the session under WinXP and Win ME OS.my program work perfectly under Win98SE but when i install my program under winXP or WINME. it popup the "Error when opening database link".

all the solution stated upper i had try even i put accpac/runtime into environement variable under WIN XP. so.. do u all have any solution for this? TQ!

RE: xAPI Session.Open problem

Microsoft has tried to keep their operating systems backward compatible. so that something written with win2000 will run well on win98, etc. However it does not work so well the other way around. Win98 to winXP is a big jump that your win98 program may not be able to handle. Unfortunatly the easiest solution would be to upgrade your program to make sure that it works on those operating systems. That usually means redeveloping them on the new OS. Sometimes it a very simple thing, sometimnes not. I do all my development on Win2000. It seems to give me the least amount of grief with your issue. With winME I wouldn't even bother with it. Instead I would advise the user to change their operating system.

Thanks and Good Luck!


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close