XBrowse with ADT Free Table

XBrowse with ADT Free Table

Postby teddydjohan » Thu Sep 07, 2017 8:55 am

Guys,

Need guidance on retrieving Advantage Database table into xBrowse. I am using the following packages:
1. xHarbour10205_bcc58 from whosaway.com
2. bcc582 from whosaway.com
3. Advantage Database version 8.1

I have done the following so far:
    Downloaded ACE SDK ver 8.1 from Advantage Dev Zone. Copy ace32.dll, adsloc32.dll, axcws32.dll to c:\windows. Copy ace.h to fivewin include folder
    Built ace32.lib from the ACE SDK Ver 8.1 using this command implib ace32.lib ace32.dll. Copy ace32.lib to xHarbour lib folder
    Downloaded the xHarbour10205 contrib folder from whosaway.com. Compile ads1.c adsfunc.c and adsmgmnt.c. Built rddads.lib using this command tlib rddads.lib +ads1.obj +adsfunc.obj +adsmgmnt.obj. Copy rddads.lib to xHarbour lib folder.

    Copy ads.ch, adsexternal.ch, rddads.ch, ace.h to xHarbour include folder.

I compiled my program successfully but when I run it, it fails with exception:
Error BASE/1001 Undefined function: ADSKEYNO

This is my program:
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"
#include "ads.ch"

REQUEST ADS
EXTERNAL AdsKeyCount, AdsGetRelKeyPos, AdsSetRelKeyPos

static oWndMain, oWndBias

memvar cXK

#DEFINE cDBPathDir          CurDrive()+":\"+CurDir()+"\"
#DEFINE cBiasSpecTable      "
TL_TirN.Adt"


//--BEG - Main() ---------------------------------------------------------------------------

function Main()

    local oFont
    private cXK := "
BRW"

    Init()

    DEFINE FONT oFont NAME "
Arial" SIZE 0, -12

    DEFINE WINDOW oWndMain TITLE "
Production 3 Result" ;
        MDI MENU BuildMenu() VSCROLL HSCROLL

    DEFINE MSGBAR PROMPT "
Production 3 Application" ;
        OF oWndMain KEYBOARD DATE TIME

   

    ACTIVATE WINDOW oWndMain MAXIMIZED VALID MsgYesNo( "
Exit Application?" )

    DisplayBiasProduct()

    RELEASE oFont

return nil

//-- END - Main() ----------------------------------------------------------------------------

//-- BEG - Init() ----------------------------------------------------------------------------
function Init()

    SET EXACT ON
    SET AUTOPEN ON
    SET EPOCH TO ( YEAR( DATE() ) - 50 )
    SET DATE FORMAT 'DD-MM-YY'  // Indonesia
    SET 3DLOOK ON
    SET DIRCASE  MIXED
    SET FILECASE MIXED

    RDDSETDEFAULT( "
ADS" )
    AdsSetServerType( ADS_LOCAL_SERVER )
    AdsSetFileType( ADS_ADT )
    AdsLocking( .F. )
    AdsRightsCheck( .F. )
    Set( _SET_OPTIMIZE, .T. )

return nil
//-- END - Init() ----------------------------------------------------------------------------

//-- BEG - BuildMenu() ----------------------------------------------------------------------------

//function BuildMenu( oWndMain )
function BuildMenu()
   
    local oMenu

    MENU oMenu

        MENUITEM "
View"
            MENU
                MENUITEM "
Product Code - Bias" ;
                    ACTION DisplayBiasProduct()
        ENDMENU

        oMenu:AddMdi()

    ENDMENU
   
return oMenu

//-- END - BuildMenu() ----------------------------------------------------------------------------


//-- BEG - getTableName( inDBPathDir ) ----------------------------------------------------------------------------
function getTableName( inDBPathDir )

    local cTblName
    local aTokens := {}
    local numTokens

    cTblName := UPPER( inDBPathDir )        //Convert to Upper Case
    cTblName := StrTran( cTblName, "
.ADT", "")      //Remove .ADT from the inDBPathDir
    aTokens := HB_ATokens( cTblName, "
\", .F., .F.)
    numTokens := LEN( aTokens )

return aTokens[ numTokens ]
//-- END - getTableName( inDBPathDir ) ----------------------------------------------------------------------------

//-- BEG - DisplayBiasProduct() ----------------------------------------------------------------------------
function DisplayBiasProduct()
   
    local oBrw, oFont
    local cDBPathFileName := cDBPathDir + cBiasSpecTable
    local cTblName := getTableName( cDBPathFileName )
    local cPasswd := LOWER( cTblName + ALLTRIM( STR( LEN( cTblName ) ) ) )
    local cAlias := cTblName

    if oWndBias == nil

        /* DBUSEAREA( [<lNewArea>], [<cDriver>], <cName>, [<xcAlias>], [<lShared>], [<lReadonly>]) */
        DbUseArea( .T., , cDBPathFileName, cAlias, .T. , .T. )

        //Decrypt the table
        if  ( (cAlias)->( AdsIsTableEncrypted() ) ) .AND. (cAlias)->( AdsEnableEncryption(cPasswd) ) == 0
                ? "
Successful Decrypting Table"
        else
                //? "
Error Decrypting Table"
        endif

        DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-21

        DEFINE WINDOW oWndBias FROM 0, 0 TO 40, 90 MDICHILD OF oWndMain TITLE "
Bias Tire Specification"


        @ 0, 0 XBROWSE oBrw ;
            FONT oFont ;
            FIELDS (cAlias)->SPKCD, ;
                    (cAlias)->PBCD, ;
                    (cAlias)->SIZE, ;
                    (cAlias)->INCH, ;
                    (cAlias)->BRND, ;
                    IF( cXK == 'BRW' , ;               
                        IF( (SUBSTR((cAlias)->SPKCD,2,1)$'BDS'), ;
                            LEFT((cAlias)->SPKCD,1)+(cAlias)->PTNX+' '+(cAlias)->PTRN, ;
                            'S'+(cAlias)->PTNX+' '+(cAlias)->PTRN), ;
                            (cAlias)->PTNX+(cAlias)->PTRN ;
                       ), ;
                    (cAlias)->PR ;
            HEADERS "
Spec Code", ;
                    "
Ver", ;
                    "
Tire Size", ;
                    "
Inch", ;
                    "
Brand", ;
                    "
PTRN", ;
                    "
PR";
            AUTOSORT ;
            OF oWndBias ;
            ALIAS (cAlias)

        oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
        oBrw:CreateFromCode()
        //oBrw:SetFocus()
        oWndBias:oClient := oBrw
        oWndBias:Refresh()

        ACTIVATE WINDOW oWndBias VALID( (cAlias)->( DbCloseArea() ), oBrw:cAlias := nil, oWndBias := nil, .T. )

        RELEASE oFont
   
    else
       
        oWndBias:SetFocus()
   
    endif

return nil
//-- END - DisplayBiasProduct() ----------------------------------------------------------------------------



This is my database table:
https://drive.google.com/open?id=0B2zQUQq-PXH1VVRfOTJMY2xRS3M

This is my program:
https://drive.google.com/open?id=0B2zQUQq-PXH1MFpXcmZJLVRkSU0

Could anyone please guide me on how to proceed? Thank you.



Teddy
teddydjohan
 
Posts: 18
Joined: Wed Aug 16, 2017 5:38 am

Re: XBrowse with ADT Free Table

Postby nageswaragunupudi » Thu Sep 07, 2017 9:45 am

Please add ADSKEYNO also to the list of EXTERNAL symbols
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse with ADT Free Table

Postby teddydjohan » Thu Sep 07, 2017 9:59 am

nageswaragunupudi wrote:Please add ADSKEYNO also to the list of EXTERNAL symbols


Nages,

Alright. That solves the AdsKeyNo error.

However, when the xbrowse window pops up, the application crashes giving no detail information. It just says that the xxx.exe has stopped working.

How do I debug this? Thanks.
teddydjohan
 
Posts: 18
Joined: Wed Aug 16, 2017 5:38 am

Re: XBrowse with ADT Free Table

Postby teddydjohan » Fri Sep 08, 2017 4:37 am

Try changing the output using browse() instead of xbrowse and I find out that the browse window display empty records. This may be why the app crash when I display it using xbrowse.

The table is not empty. There are several records in the table.

Is there something wrong with the rddads.lib that I built, which is causing no records being pulled from the table? Thanks.
teddydjohan
 
Posts: 18
Joined: Wed Aug 16, 2017 5:38 am

Re: XBrowse with ADT Free Table

Postby Marcelo Via Giglio » Fri Sep 08, 2017 1:25 pm

Hola,

I only changed the adt file name and the password

Code: Select all  Expand view

......
    /* DBUSEAREA( [<lNewArea>], [<cDriver>], <cName>, [<xcAlias>], [<lShared>], [<lReadonly>]) */
        //DbUseArea( .T., , cDBPathFileName, cAlias, .T. , .T. )
      DbUseArea( .T., , "TL_TirN", cAlias, .T. , .T. )

        //Decrypt the table
        if  ( (cAlias)->( AdsIsTableEncrypted() ) ) .AND. (cAlias)->( AdsEnableEncryption("tl_tirn7") ) == 0
                ? "Successful Decrypting Table"
        else
                //? "Error Decrypting Table"
        endif
......
 


and I can see the xBrowse with the table's contents

saludos

Marcelo
Marcelo Via Giglio
 
Posts: 1050
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: XBrowse with ADT Free Table

Postby teddydjohan » Sat Sep 09, 2017 1:37 am

Marcelo Via Giglio wrote:Hola,

I only changed the adt file name and the password

Code: Select all  Expand view

......
    /* DBUSEAREA( [<lNewArea>], [<cDriver>], <cName>, [<xcAlias>], [<lShared>], [<lReadonly>]) */
        //DbUseArea( .T., , cDBPathFileName, cAlias, .T. , .T. )
      DbUseArea( .T., , "TL_TirN", cAlias, .T. , .T. )

        //Decrypt the table
        if  ( (cAlias)->( AdsIsTableEncrypted() ) ) .AND. (cAlias)->( AdsEnableEncryption("tl_tirn7") ) == 0
                ? "Successful Decrypting Table"
        else
                //? "Error Decrypting Table"
        endif
......
 


and I can see the xBrowse with the table's contents

saludos

Marcelo


Hi Marcelo,

Thanks for your effort and suggestion but I am still getting nothing on my side. It works fine if I use DBF tables but it is not showing anything when I use ADT tables. That's why I assume there might be something wrong with the configuration for RDDADS in my environment.

Any suggestion on this matter? Thanks.
teddydjohan
 
Posts: 18
Joined: Wed Aug 16, 2017 5:38 am

Re: XBrowse with ADT Free Table

Postby Marcelo Via Giglio » Sat Sep 09, 2017 1:45 am

Hola,

how I said, I only change the table's name (directly puting the name) and put directly the password, and I could saw the browse with the data. Maybe you need to review the DLL version and the ACE32 version, all need to be the same

suerte

Marcelo
Marcelo Via Giglio
 
Posts: 1050
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: XBrowse with ADT Free Table

Postby teddydjohan » Sat Sep 09, 2017 2:02 am

Marcelo Via Giglio wrote:Hola,

how I said, I only change the table's name (directly puting the name) and put directly the password, and I could saw the browse with the data. Maybe you need to review the DLL version and the ACE32 version, all need to be the same

suerte

Marcelo


ace32.dll, adsloc32.dll, and axcws32.dll are from AceSDK ver 8.1.
ace32.lib was built from ace32.dll of AceSDK Ver 8.1
rddads.lib was built from ads1.c, adsfunc.c, and adsmgmnt.c of xHarbour 1.2.3 rev 10205 contrib folder.

Do I need to find a specific previous version of xHarbour contrib rddads folder?
teddydjohan
 
Posts: 18
Joined: Wed Aug 16, 2017 5:38 am

Re: XBrowse with ADT Free Table

Postby Marcelo Via Giglio » Sat Sep 09, 2017 3:15 am

Dear Teddy,

I'm using dlls and libraries from ADS v 10, try to use them

best regards

Marcelo
Marcelo Via Giglio
 
Posts: 1050
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 26 guests