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!

Starting an Accpac Session usine vb.NET 1

Status
Not open for further replies.

planetbluau

Programmer
May 25, 2010
54
AU
I am trying to incorporate code to programatically add an OE record. I'm developing on VS2010 using vb.net as the rest of the program is in that same version.

I'm having trouble logging on to an Accpac Session.

The code I am using is:

Dim session = New AccpacCOMAPI.AccpacSession
session.Init("", "XY", "XY0001", "56A")
session.Open("ADMIN", "ADMIN", "XYZDAT", Now.Date, 0, 0)

I get the error that the login is incorrect and finally, Error HRESULT E_FAIL has been returned from a call to a COM component.

I understand that the equivalent VBA code is:
Set Session = AccpacCOMAPI.AccpacSession
Session.Init "", "XY", "XY0001", "56A"
Session.Open "ADMIN", "ADMIN", "XYZDAT", Date, 0, 0

Can anyone tell me what I am doing wrong? (At least in this case ;-)
 
I only have code that invokes the signon manager but perhaps it will help:
Code:
    Private Function SignOnToAccpac() As Boolean
        SignOnToAccpac = True
        If Not (Session Is Nothing) Then
            Exit Function
        End If
        lSignonID = 0 ' MUST be initialized to 0 since you don't have a signon ID yet
        sessmgr = New AccpacSessionManager.AccpacSessionMgr
        With sessmgr
            .AppID = "XY"
            .AppVersion = "55A"
            .ProgramName = "XY0001"
            .ServerName = "" ' empty string if running on local computer
            .ForceNewSignon = True
            .CreateSession("", lSignonID, Session) ' first argument is the object handle (if you don't have one, pass "")
        End With ' mSessMgr
        If IsNothing(Session) Then
            SignOnToAccpac = False
        Else
            OpenAndComposeViews()
        End If

    End Function
 
Thank you for the code. With a little more experimenting, I found that the NOW.Date function was causing the issue.

The code that worked is:

Dim session = New AccpacCOMAPI.AccpacSession
session.Init("", "XY", "XY0001", "56A")
session.Open("ADMIN", "ADMIN", "XYZDAT", CDate(Now.Date.ToShortDateString), 0, "")


Of course the code also has:
Imports AccpacCOMAPI.tagDBLinkFlagsEnum
Imports AccpacCOMAPI.tagDBLinkTypeEnum

Thank you again.
 
You could just use


Dim session = New AccpacCOMAPI.AccpacSession
session.Init("", "XY", "XY0001", "56A")
session.Open("ADMIN", "ADMIN", "XYZDAT", today, 0, "")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top