How to capture the data returned wSDBSelectRecords in sage 50 2016 CA SDK with Visual Basic .NET?

I´m using ConnectionManagerService.dll and I am using the function wSDBSelectRecords with this syntax: 

Call wSDBSelectRecords(iDBLink, iTBLink, "", 0, True)

But I do not know how to capture the data you are going to select in a DataTable. I´m Working with Visual Basic .NET Fraework 4.5

Could help me with this?

  • wSDBFetchRecord
    Definition WORD wSDBFetchRecord(WORD wDBLinkNo, WORD wTBLinkNo, LPVOID pRecord, WORD wFetch, LPWORD pFetched)
    Description wSDBFetchRecord retrieves one or more records from a table, based on the selection criteria specified on wSDBSelectRecords or wSDBExecSelectSQL
  • I do not know if I'm doing it correctly. I declare the functions as follows.

    Public Declare Function wSDBSelectRecords Lib "Sage_SA_dblyr.dll" (ByVal wDBLinkNo As Short, ByVal wTBLinkNo As Short, ByVal pszFilter As String, ByVal wKey As Short, ByVal wFlags As Boolean) As Short

    Public Declare Function wSDBFetchRecord Lib "Sage_SA_dblyr.dll" (ByVal wDBLinkNo As Short, ByVal wTBLinkNo As Short, ByVal pRecord As Byte(), ByVal wFetch As Short, ByVal pFetched As Byte()) As Short

    And when I execute the functions with the following parameters:

    Dim pCount As Short
    Dim pRecord2(1999) As Byte
    Dim pFetched(1999) As Byte

    Call wSDBSelectRecords(iDBLink, iTBLink, "", 0, True)
    Call wSDBFetchRecord(iDBLink, iTBLink, pRecord2, pCount, pFetched)

    I do not know where or how to view the records returned for the function, to work with them.
  • Hi,

    in wSDBSelectRecords(iDBLink, iTBLink, "", 0, True), it looks like the "" is where you need a pointer to a string that contains the criteria.

    An empty string might contain a null terminator char 255, or nothing at all, and select no results for the next line of code to fetch.

    I would use one of the database utility functions as used in the sample file in the c# folder. It doesn't appear that the VB sample is as complex as the c# one, I don't know how portable it is between the .NET flavours.