Sage 50 CA SDK and Delphi

SUGGESTED

We program in Delphi and I’m attempting to access a Sage 50 2019 database using the SDK, question is, can the SDK be used in a Delphi environment ?  I’ve made a program (based on the C++, C#, VB code samples) to simply open (wSDBOpenDatabase) and close (wSDBCloseDatabase) a database but I can’t get the damn thing to open.

I’ve loaded the sage_sa_dblyr.dll ;  LoadLibrary('sage_sa_dblyr.dll')

I’ve accessed the wSDBOpenDatabase routine ;  GetProcAddress('wSDBOpenDatabase')
Everything thus far seem to be pointing to a faulty function declaration :

  SAGE50_wSDBOpenDatabase : function (
              var pwDBLinkNo : PWord;
              wFlags : Word;
              sAppID : PChar;
              sUserID : PChar;
              sPwd : PChar;
              sServerId : PAnsiChar;
              sCompId : PAnsiChar;
              sPort : PAnsiChar)
              :Word; stdcall;

The GetConnectionInfo routine seems to work but the SAGE50_wSDBOpenDatabase always returns error code 130 (DBS_BAD_PW).

To my knowledge, the user (3rd party read/write access allowed) and password (proper case and under 8 characters) check out.

When I send an invalid User ID, I still get error code 130 (DBS_BAD_PW).
When I send an invalid Server ID, I get error code 118 (DBS_LOCKED).
When I send an invalid Port, I get error code 118 (DBS_LOCKED).

  • 0

    I don't program in Delphi and I don't use the SDK but some people are not aware that the username is also case-sensitive.  Check the Home screen of Sage 50 when logged in with the username.  In the bottom-right corner, it shows the case of the username (regardless of how you logged into Sage 50).

    Can you get the original compiled SDK code samples to open the file with the username and password you are using?

  • 0 in reply to Richard S. Ridings

    Thanks for the quick reply !

    User ID case looks good (I've been using the stock "sysadmin" ID).

    Sadly I do not have access to a C#, C++ or VB compiler but I’ll be sure to look into that option.

  • 0 in reply to bob@sigm

    Sorry, you misunderstood.  I didn't suggest you compile the sample project, only that you use the supplied compiled version of the sample program.  In the ..\Sample\vb.net folder for example, you will find Sample.exe.  This should function for you without compiling yourself.

    If you are using the "stock" sysadmin username, did you enter a password into the Sage 50 datafile for that username?  If not, then don't use any password in your application, just use the username sysadmin.

  • 0 in reply to Richard S. Ridings

    I've ran all 3 Sample executables and they all work fine.

    At first, sysadmin did indeed have a blank password.  So I ran a test with and without a password in the sysadmin user file and both resulted in a DBS_BAD_PW (130) error.

  • 0 in reply to bob@sigm

    Sorry, I can't help any further.  I know nothing about Delphi.  It's possible your conversion of data or data types are not being recognised properly between languages.  You might want to check on the MySQL website community to see if there are any differences in connections with the Delphi environment vs. Visual Studio.

    Have you checked to make sure the info returned by GetConnectionInfo for Port and Server are correct?  It likely is or you might be getting a different error message (eg. 98 or 119) but I thought I would mention it.

    If the data file is on the local computer, it might work better using localhost for the ServerID instead of the real computer name.

  • 0 in reply to Richard S. Ridings

    My GetConnectionInfo appears to be working fine, function result returns 0, Server ID returns "localhost" and Port returns "13540".

    I've indeed been using "localhost" this whole time.

    My gut also says I've got a parameter data type issue.

    No worries and thanks for the input.

  • FormerMember
    0 FormerMember
    SUGGESTED

    I was able to get this working with a small change to the function declaration; simply change the PChar items to PAnsiChar:

      SAGE50_wSDBOpenDatabase: function(

        var
        pwDBLinkNo: PWord;
        wFlags: Word;
        sAppID: PAnsiChar;
        sUserID: PAnsiChar;
        sPwd: PAnsiChar;
        sServerId: PAnsiChar;
        sCompId: PAnsiChar;
        sPort: PAnsiChar

        ): Word; stdcall;