How do I know if the connection to the database is open ?

I´m working with sage 50 CA 2016 SDK, and i have a problem with database connection.

When I run this code in a console application successfully opens the connection, but when I run the same code in a Winform application , does not open the connection, return false. 

And I have a theory, that is because the connection one way or another , is open. But I do not know how to get my connection status (open or closed ).

if (SDKInstanceManager.Instance.OpenDatabase(pSaiFile, pUsername, pPassword, false, "Sage 50 SDK Sample Program", "SASDK", 1))
{
      //Code

}


Somebody could help me? i´m working with C#.

Parents
  • 0
    The code is returning the success, or not, of instance.OpenDatabase. If the connection is already open, it may return a fail.

    If you have the Connection Manager taskbar program open, it should show the number of active connections. If a connection is currently open, the MySql Daemon should be running.

    After closing the application, or an SDK application, connections do stay open for a period of time before all files are closed. You'll notice this more if trying to apply a file attribute (i.e. Archive as in 'Attrib +A *.* /s') to the files in the data folder, or trying to eject a USB device.

    Some other wierdnesses:
    The SDK will accept a password string longer than 7 characters, but it won't just match the first 7 characters, it does whatever it does, on the whole string. (i.e. 'password' was being truncated by the user interface to 'passwor', but 'password' would fail)

    I would truncate all passwords to 7 char. The user name in the SDK seems to be case-sensitive - i.e. 'sysadmin' could log in, but SYSADMIN couldn't.

    I hope that helps, please post back!
  • 0 in reply to RandyW

    RandyW said:
    If you have the Connection Manager taskbar program open, it should show the number of active connections. If a connection is currently open, the MySql Daemon should be running.

    Only if the data file is on the local computer.  If the *.sai file is on another computer/server, the local Connection Manager does not show any details.

    If you run the Sage 50 file in multiuser mode in the program, File, Properties will tell you if anyone else is logged in.
     

    RandyW said:
    Some other wierdnesses:
    The SDK will accept a password string longer than 7 characters, but it won't just match the first 7 characters, it does whatever it does, on the whole string. (i.e. 'password' was being truncated by the user interface to 'passwor', but 'password' would fail)

    I would truncate all passwords to 7 char. The user name in the SDK seems to be case-sensitive - i.e. 'sysadmin' could log in, but SYSADMIN couldn't.

    This is just my opinion but I believe the MySQL program is managing the passwords not the SDK and therefore creating this "weirdness".  Sage's programming in Sage 50 bypasses the database case-sensitivity of the userid when in the Sage 50 program and restricts the length of the password for various reasons.  I believe the userid should be case-sensitive as is the password but I believe because historical programming that dates back into the 90's never required the case-sensitive nature of the user id, Sage has maintained that behaviour in current versions for consistency.

  • 0 in reply to Richard S. Ridings

    Richard S. Ridings said:
    This is just my opinion but I believe the MySQL program is managing the passwords not the SDK and therefore creating this "weirdness".  Sage's programming in Sage 50 bypasses the database case-sensitivity of the userid when in the Sage 50 program and restricts the length of the password for various reasons.

    I believe that's how it works, probably the Sage 50 client converts the case of the username, and of course truncates the password. 

    I was just pointing out that if the test filename, user name and password aren't embedded in the code during testing, it's too easy to type Sysadmin, sysadmin, or SYSADMIN at various times and think you did the same thing but it didn't work.   Occam's Razor. 

Reply
  • 0 in reply to Richard S. Ridings

    Richard S. Ridings said:
    This is just my opinion but I believe the MySQL program is managing the passwords not the SDK and therefore creating this "weirdness".  Sage's programming in Sage 50 bypasses the database case-sensitivity of the userid when in the Sage 50 program and restricts the length of the password for various reasons.

    I believe that's how it works, probably the Sage 50 client converts the case of the username, and of course truncates the password. 

    I was just pointing out that if the test filename, user name and password aren't embedded in the code during testing, it's too easy to type Sysadmin, sysadmin, or SYSADMIN at various times and think you did the same thing but it didn't work.   Occam's Razor. 

Children