Using existing connection in Accpac Advantage

Hi Everyone,

I am now developing a .NET exe and Accpac.Advantage to open the view and import into Sage. But currently how I design is using the one sage login to open the view and do the stuff inside the program. Now I would like to change it to use the current Sage login User so that I don't have to store the login detail inside the program. Please help to advise. Below is my current code to open the view and I want to change it to use the current sage user. Thank you in advance.

session = new ACCPAC.Advantage.Session();
session.Init("", "XY", "XY1000", "70A");
string userID = Settings.Default.mUsername;
string password = Settings.Default.mUserpassword;
string companyid = Settings.Default.mDatabasename;
session.Open(userID, password, COMPANY, DateTime.Today, 0);
mDBLinkCmpRW = session.OpenDBLink(ACCPAC.Advantage.DBLinkType.Company, ACCPAC.Advantage.DBLinkFlags.ReadWrite);

Parents
  • I use the code below in programs with a form, it will use the existing user's Sage session.  If the user isn't logged into Sage, it will pop up the regular login screen.

    public static AccpacSession session ;
    public static AccpacDBLink a4wLink;
    public static AccpacDBLink a4wLinkRead;
    public static AccpacSessionMgr sessionmgr;

    sessionmgr = new AccpacSessionMgr(); // As New AccpacSessionMgr
    Int32 sid = 0;

    sessionmgr.AppID = "XY";
    sessionmgr.ProgramName = "XY1000";
    sessionmgr.AppVersion = "60A";
    sessionmgr.CreateSession("", sid, out Globals.session);
    a4wLink = Globals.session.OpenDBLink(tagDBLinkTypeEnum.DBLINK_COMPANY, tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);
    a4wLinkRead = Globals.session.OpenDBLink(tagDBLinkTypeEnum.DBLINK_COMPANY, tagDBLinkFlagsEnum.DBLINK_FLG_READONLY);
    sMigratorUser = Globals.a4wLink.Session.UserID;
    sMigratorCompany = Globals.a4wLink.Session.CompanyID;

  • 0 in reply to Jay Converse Acumen

    Hi Sir, Thank you for your help and showing me how to do it. But i would like to ask one thing. Where does this Globals.session come from? Thanks again.

Reply Children
No Data