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

Connect Accpac in Asp.net web service application 1

Status
Not open for further replies.

thanet

Programmer
Apr 16, 2015
11
TH
Dear All,

Can I use code below to connect Accpac in asp.net web service (it is fine in windows form application)?

Dim Session As New AccpacSession
Dim mDBLinkCmpRw As AccpacDBLink
Dim mSessMgr As AccpacSessionMgr
Dim mlSessionID As Long
'Open Session
mlSessionID = 0
mSessMgr = Nothing
Session = Nothing
If mSessMgr Is Nothing Then
mSessMgr = CreateObject("Accpac.SessionMgr")
With mSessMgr
'Set the session manager's properties.
.AppID = "XY"
.AppVersion = "61A"
.ProgramName = "XY0001"
End With ' mSessMgr
End If
'Only create the session if it doesn't already exist
If Session Is Nothing Then
mSessMgr.CreateSession("", mlSessionID, Session)
mDBLinkCmpRw = Session.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
End If

Error:

accpac_ynx2z6.png



System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) at AccpacSessionManager.IAccpacSessionMgr.CreateSession(String ObjectHandle, Int32& SignonID, AccpacSession& Session)
 
Make sure the Sage client is installed and running on the IIS server.

Sage 300 Whisperer
 
Hi Jay,

They are on the same server.
 
You don't need a session manager unless you plan to run UIs or macros. Otherwise, you can just create a session object. Plus, in your code example, you didn't open a session properly. You indicated that it worked on a workstation but I don't see where you specify the company you want to connect to, the session date, user or password. That makes me think that the signon screen was probably appearing.

Code:
set MySession = New AccpacCOMAPI.AccpacSession
MySession.Init(some parameters)
MySession.Open(this is where you supply company, user, pw, date)
set MyDBLink = MySession.OpenDBLink(some parameters)

Now you'll be able to open views, process transactions, generate reports, etc. No signon manager required.
 
Hi DjangMan ,
Thanks for you good support.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top