SDK OpenDatabase: Unable to open the company file

I get the “Unable to open the company file” exception when calling SimplySDK.SDKInstanceManager.Instance.OpenDatabase.

I reviewed the FAQ in the documentation of the SDK.

I have made sure that the database file and the SDK have the same version, 21201, which is the latest one I believe. I have checked and re-checked the username and password. I have made sure the username has third-party access rights read/write. I have even switched the database to multi-user in case, making sure to adjust the parameter in the call to OpenDatabase, but to no avail.

Any clue of what else could be wrong?

The errorlog.txt shows that the connection manager is starting properly...

Does the length of the path to the .SAI file is limited?

Thank you.

Luc.

Parents
  • 0

    Hi Luc,

    I would think that the pathname is only limited by the OS, but a quick test in say C:\work  should tell you.

    Another thing, the password entered is truncated to 7 characters by the Sage 50 interface, but the entire string is evaluated when matching.  Make sure the password you're using is no more than 7 characters, longer than 7 chars will always be a mismatch.

    Try to connect with ODBC using that username / password to test the data connection.

    Try opening the database from Sage 50 in multi-user, then start your app, using the path showing in Sage 50 under File | properties.   The connection should show up in File | Properties if it's getting all the way through the Connection Manager to MySQL.

    I hope that helps, please post back.

    Randy

  • 0 in reply to RandyW

    I was passing the full path including the .SAI, as indicated in the SDK documentation. Should it be the full path including the .SAI filename?

    If I put only the path, I do not get the exception, but the OpenDatabase method returns False. And obviously, the connection does not show up in File | Properties.

    Should I pass only the path, or the path including the .SAJ folder? The other methods in the SDK are using the .SAJ path to open a connection. I tried the .SAJ path, and I do not get an exception, but no connection.

    I am a bit confused...

    Thank you for your help!

    Luc.

  • 0 in reply to lutrin

    Hi Luc,

    OpenDatabase definitely takes the full name and pathname of the .SAI file.

    In the SDK Sample.cs, in the 'Main' section, the sample code asks for a filename, converts it to uppercase, checks to see that the filename passed ends with .SAI, and that it exists, and that the .SAJ folder exists.

    The variable 'saiFile' passed in code used to open the database, is a string value containing the full name and pathname of the .SAI file, as you would type it at a command prompt.  (you don't need to do anything fancy, like use \\ to ESCape the pathname backslashes)

    if (SDKInstanceManager.Instance.OpenDatabase(saiFile, username, password, false, "Sage 50 SDK Sample Program", "SASDK", 1))

    So, if you pass your program the full filename like:

    C:\Users\Public\Documents\Simply Accounting\2014\SAMDATA\Enterprise\Universl.SAI

    it should open the file.    I haven't done that much with the SDK, however I did have these difficulties with a prior release of the SDK, using c#:

     - It wouldn't consistently open a file, unless it was already open in Sage 50, or had very recently (in the past few minutes) been opened in Sage 50.   The Connection Manager perhaps checks whether a licensed workstation copy of the program has to opened the database, then just quietly ignores any other attempts.  This is definitely the behavior of ODBC connections - the database always has to have been opened in Sage 50 first, in multi-user mode.

     - The password behaviour was finicky - there is no password on the sample file, but it wouldn't (or I didn't correctly tell it to) accept an empty password.  Then I thought I had set up an 8 character password, but it was truncated, so there was a mismatch.


     

Reply
  • 0 in reply to lutrin

    Hi Luc,

    OpenDatabase definitely takes the full name and pathname of the .SAI file.

    In the SDK Sample.cs, in the 'Main' section, the sample code asks for a filename, converts it to uppercase, checks to see that the filename passed ends with .SAI, and that it exists, and that the .SAJ folder exists.

    The variable 'saiFile' passed in code used to open the database, is a string value containing the full name and pathname of the .SAI file, as you would type it at a command prompt.  (you don't need to do anything fancy, like use \\ to ESCape the pathname backslashes)

    if (SDKInstanceManager.Instance.OpenDatabase(saiFile, username, password, false, "Sage 50 SDK Sample Program", "SASDK", 1))

    So, if you pass your program the full filename like:

    C:\Users\Public\Documents\Simply Accounting\2014\SAMDATA\Enterprise\Universl.SAI

    it should open the file.    I haven't done that much with the SDK, however I did have these difficulties with a prior release of the SDK, using c#:

     - It wouldn't consistently open a file, unless it was already open in Sage 50, or had very recently (in the past few minutes) been opened in Sage 50.   The Connection Manager perhaps checks whether a licensed workstation copy of the program has to opened the database, then just quietly ignores any other attempts.  This is definitely the behavior of ODBC connections - the database always has to have been opened in Sage 50 first, in multi-user mode.

     - The password behaviour was finicky - there is no password on the sample file, but it wouldn't (or I didn't correctly tell it to) accept an empty password.  Then I thought I had set up an 8 character password, but it was truncated, so there was a mismatch.


     

Children
No Data