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).

Parents
  • 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;

Reply
  • 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;

Children
No Data