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

Log on the the current session from custom app

Status
Not open for further replies.

vbdbcoder

Programmer
Nov 23, 2006
247
US
I have had this issue forever and I don't recall there is a fix to it. When a custom app uses session manager to log on to a session, it works perfect when there is only one session opened. However, when there is more than 1 sessions opened (Comp A and Comp B), the session manager from the custom app is confused, and prompts a screen to select which session to log on. I am just curious if there is fix, other than the SDK approach?

Code:
private void log_On_Existing_Accpac_Session()
{
try
{
vSessionMgr.AppID = AppID;
vSessionMgr.AppVersion = AppVersion;
vSessionMgr.ProgramName = ProgramName;
vSessionMgr.ServerName = ServerName;
vSessionMgr.CreateSession("", 0, out myAccpacSession); //this is graping the session from session manager, prompts to select from a list if more than 1 company is opened...
myAccpacSession.GetSignonInfo(out sAccpacUser, out sAccpacCompany, out sCompany2);
oDBLink = myAccpacSession.OpenDBLink(tagDBLinkTypeEnum.DBLINK_COMPANY, tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);

this.Text = "Custom Import [" + sAccpacCompany + "] - " + sCompany2;

toolStripStatusLabel1.Text = "User ID: " + sAccpacUser;
toolStripStatusLabel2.Text = "Company ID: " + sAccpacCompany;
toolStripStatusLabel3.Text = sCompany2;
toolStripStatusLabel4.Text = "Version: " + Application.ProductVersion + " for Sage 300 v " + myAccpacSession.AppVersion;

//lblSelectedShipments.Text = "No Shipment Selected. Shipment Total: $0.00";
}
catch (Exception ex)
{
MessageBox.Show("Fatal Error: " + ex.Message + "\nInternal Error Message: " + ex.InnerException, "Fatal Eror: Can't Logon to Accpac");
this.Close();
this.Dispose();
}
}

 
[tt]Ugh - now I can't find the information. Somewhere - it might just be starting in 2016 (but it could be in 2014) but you'll be able to generate a code via the session object that you can pass to your session.init call in the first parameter. That would all you to connect to an existing session instead of being at the mercy of the signon manager. It looked like you would be able to generate this code in a VBA macro allowing you to create a macro to generate and pass the code to your custom executable via command line. That would give you an easy way to run your screens with company specific information being passed to your program.

Found it:
[/tt]
 
That is great help, DjangMan!!! I will try ... I will have to use C# instead, hoping "a4wroto.dll" to work in .NET.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top