Sage 2017 - 64A can't login through C# App.

SOLVED

Wrote simple app to simulate login into Sage 300 in C#

i can query the company names... but when i try to actually use a password and login user it gives me Invalid Signon Information error message, anyone know what i'm doing wrong?

session = new ACCPAC.Advantage.Session();
session.Init("", "XX", "XX1000", "64A");
foreach (Organization org in session.Organizations)
{
if (org.Type.ToString() == "Company")
{
Company.Items.Add(org.Name);
}
Info.Text += "Company ID: " + org.ID + " Name: " + org.Name + " Type: " + org.Type + "\r\n";
}

session.Open("BOB", "somePassword", Company.Text, DateTime.Today, 0);
mDBLinkCmpRW = session.OpenDBLink(ACCPAC.Advantage.DBLinkType.Company, ACCPAC.Advantage.DBLinkFlags.ReadWrite);

Parents
  • 0

    Edit: I see that you've already got this part.  I'll see if I can dig up the Windows Auth code

    Edit 2: If you're going to use a Windows login, be sure to call sess.OpenWin and not sess.Open.

    I haven't checked this code for a while but given that you don't have to be signed on to access the list of Orgs then you can make use of the AccpacOrganizations object.

    Dim Orgs As AccpacCOMAPI.AccpacOrganizations
    Dim sess As AccpacCOMAPI.AccpacSession
    Dim Org As AccpacCOMAPI.AccpacOrganization

    Set sess = New AccpacCOMAPI.AccpacSession
    sess.Init "", "XY", "XY0001", "61"
    Set Orgs = sess.Organizations
    Orgs.Reset

    While Orgs.Next(Org)
      If Org.Type = ORG_COMPANY Then
        debug.print Trim$(Org.Name)
      End If
    Wend


    Set Org = Nothing
    Set Orgs = Nothing
    Set sess = Nothing

Reply
  • 0

    Edit: I see that you've already got this part.  I'll see if I can dig up the Windows Auth code

    Edit 2: If you're going to use a Windows login, be sure to call sess.OpenWin and not sess.Open.

    I haven't checked this code for a while but given that you don't have to be signed on to access the list of Orgs then you can make use of the AccpacOrganizations object.

    Dim Orgs As AccpacCOMAPI.AccpacOrganizations
    Dim sess As AccpacCOMAPI.AccpacSession
    Dim Org As AccpacCOMAPI.AccpacOrganization

    Set sess = New AccpacCOMAPI.AccpacSession
    sess.Init "", "XY", "XY0001", "61"
    Set Orgs = sess.Organizations
    Orgs.Reset

    While Orgs.Next(Org)
      If Org.Type = ORG_COMPANY Then
        debug.print Trim$(Org.Name)
      End If
    Wend


    Set Org = Nothing
    Set Orgs = Nothing
    Set sess = Nothing

Children