FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ADO RDD xHarbour
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Wed Apr 01, 2015 10:20 AM

Antonio,

My suggestion is to test it, as much as possible, by you and other users. Its the only way to know if it will work fine.

Regarding the failure, you should raise an error object. Please review arrayrdd.prg for an example

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: ADO RDD xHarbour
Posted: Wed Apr 01, 2015 01:35 PM

In case you may be interested
Two functions ADO to FWH
- Clear Table
- Mostras database tables (other than those included in FW AdoFuncs)

Por si puede interesar
Dos funciones ADO para FWH
- Borrar tabla
- Mostras tablas de base de datos ( distinta a la incluida en FW AdoFuncs )

viewtopic.php?f=19t=27296p=164348hilit=empezando+con+ado#p164348

&&&

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Wed Apr 01, 2015 02:33 PM

Antonio,

When we use select() what function does it call in rdd?

Thanks Cristobal any help is most welcome

Regards

Antonio H Ferreira
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Wed Apr 01, 2015 03:06 PM
Antonio,

Code (fw): Select all Collapse
/*
 * Select a WorkArea by the number.
 */
HB_ERRCODE hb_rddSelectWorkAreaNumber( int iArea )
{
   PHB_STACKRDD pRddInfo;

   HB_TRACE( HB_TR_DEBUG, ( "hb_rddSelectWorkAreaNumber(%d)", iArea ) );

   pRddInfo = hb_stackRDD();
   if( iArea < 1 || iArea > HB_RDD_MAX_AREA_NUM )
      HB_SET_WA( 0 );
   else
      HB_SET_WA( ( HB_AREANO ) iArea );

   return ( pRddInfo->pCurrArea == NULL ) ? HB_FAILURE : HB_SUCCESS;
}


Code (fw): Select all Collapse
#define HB_SET_WA( n )  \
   do \
   { \
      pRddInfo->uiCurrArea = n; \
      pRddInfo->pCurrArea  = ( ( pRddInfo->uiCurrArea < pRddInfo->uiWaNumMax ) ? \
                               pRddInfo->waList[ pRddInfo->waNums[ pRddInfo->uiCurrArea ] ] : \
                               NULL ); \
   } while( 0 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: ADO RDD xHarbour
Posted: Wed Apr 01, 2015 06:47 PM
Antonio,

Option a) worked.

This is the code for Harbour:

Code (fw): Select all Collapse
#ifndef __XHARBOUR__

   #include "fivewin.ch"        // as Harbour does not have TRY / CATCH
   #define UR_FI_FLAGS           6
   #define UR_FI_STEP            7
   #define UR_FI_SIZE            5 // by Lucas for Harbour


#endif



Unfortunatelly, xBrowse() does not work.

It needs in ADO_INFO() to have DBI_FULLPATH.

I hacked like this with no luck:

Code (fw): Select all Collapse
    CASE uInfoType == DBI_FULLPATH // 10  /* The Full path to the data file      */

             MSGINFO("IN SQL FULL PATH DOES NOT MATTER!", "DBI_FULLPATH ")
             uReturn := ""



Now, I get:


Error description: (DOS Error -2147352567) WINOLE/1007 El recordset actual no admite marcadores. Puede deberse a una limitaci贸n del proveedor o del tipo de cursor seleccionado. (0x800A0CB3): ADODB.Recordset
Args:
[ 1] = N -1
[ 2] = N 0

Stack Calls
===========
Called from: => TOLEAUTO:MOVE( 0 )
Called from: lucas2.prg => ADO_GOTOID( 524 )
Called from: => DBGOTO( 0 )
Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE_SETRDD( 4083 )
Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE( 439 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:_BOOKMARK( 0 )
Called from: .\source\function\XBROWSER.PRG => FITSIZES( 283 )
Called from: .\source\function\XBROWSER.PRG => (b)XBROWSE( 220 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE( 700 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 890 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 286 )
Called from: .\source\function\XBROWSER.PRG => XBROWSE( 220 )
Called from: lucas2.prg => MAIN( 44 )
Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: ADO RDD xHarbour
Posted: Wed Apr 01, 2015 06:51 PM

In English:

The current recordset does not support bookmarks . It may be due to a limitation of the provider or cursor type selected

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Wed Apr 01, 2015 09:12 PM
Lucas,

#define UR_FI_SIZE 5 // by Lucas for Harbour

xHarbour needs 7 as the len of the array.

You succed to return the fullpath ? Why xbrowse needs fullpath?
Checking if file exists isnt still ready for SQL.

Try use CursorLocation= adUseClient ADO assures bookmarks with this cursor.

I think in a multiuser envirements using absolutepositon does not assure that you will be able to get back to that position for ex a row its deleted the rows are renumbered.

I think we should had in ado_open

if orecordset:supports(adBookmarks)
use servercursor
else
use clientcursor

I will check that later.

What DB are you using?
Regards

Antonio H Ferreira
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 07:43 AM

Antonio,

1) In hbusrdd.ch DBRELINFO what is UR_RI_NEXT for ?

2) What shall we put in ADO_INFO :

DBI_FULLPATH
DBI_TABLEEXT
DBI_FILEHANDLE

Regards

Antonio H Ferreira
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 07:55 AM

Hello,

I am using Access for the tests.

We shall ask Mr. Nages about this xBrowse() issue.

Pure Browse() works, but scrolling does not work ok.

Append blank fails.

Thank you

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 07:59 AM
Antonio,

Code (fw): Select all Collapse
static PHB_ITEM hb_usrRelInfoToItem( LPDBRELINFO pRelInfo )
{
   PHB_ITEM pItem;

   pItem = hb_itemArrayNew( UR_RI_SIZE );
   if( pRelInfo->itmCobExpr )
      hb_itemCopy( hb_arrayGetItemPtr( pItem, UR_RI_BEXPR ), pRelInfo->itmCobExpr );
   if( pRelInfo->abKey )
      hb_itemCopy( hb_arrayGetItemPtr( pItem, UR_RI_CEXPR ), pRelInfo->abKey );
   hb_itemPutL( hb_arrayGetItemPtr( pItem, UR_RI_SCOPED ), pRelInfo->isScoped );
   hb_itemPutL( hb_arrayGetItemPtr( pItem, UR_RI_OPTIMIZED ), pRelInfo->isOptimized );
   hb_itemPutNI( hb_arrayGetItemPtr( pItem, UR_RI_PARENT ), pRelInfo->lpaParent ? pRelInfo->lpaParent->uiArea : 0 );
   hb_itemPutNI( hb_arrayGetItemPtr( pItem, UR_RI_CHILD ), pRelInfo->lpaChild ? pRelInfo->lpaChild->uiArea : 0 );
   hb_itemPutPtr( hb_arrayGetItemPtr( pItem, UR_RI_NEXT ), pRelInfo->lpdbriNext );

   return pItem;
}


Code (fw): Select all Collapse
/*
 *  DBRELINFO
 *  ---------
 *  The Relationship Info structure
 */

typedef struct _DBRELINFO
{
   PHB_ITEM            itmCobExpr;   /* Block representation of the relational SEEK key */
   PHB_ITEM            abKey;        /* String representation of the relational SEEK key */
   HB_BOOL             isScoped;     /* Is this relation scoped */
   HB_BOOL             isOptimized;  /* Is relation optimized */
   struct _AREA      * lpaParent;    /* The parent of this relation */
   struct _AREA      * lpaChild;     /* The parents children */
   struct _DBRELINFO * lpdbriNext;   /* Next child or parent */
} DBRELINFO;

typedef DBRELINFO * LPDBRELINFO;
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 08:00 AM
Antonio,


2) What shall we put in ADO_INFO :

DBI_FULLPATH
DBI_TABLEEXT
DBI_FILEHANDLE


FileHandle and TableExt I would set nil to them. For FullPath you may use the database path if defined.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 08:22 AM
Antonio,

struct _DBRELINFO * lpdbriNext; /* Next child or parent */


This always comes empty. Its never used ?
Regards

Antonio H Ferreira
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 08:29 AM
lucasdebeltran wrote:

Pure Browse() works, but scrolling does not work ok.


Can you be more precise? Here Browse() works fine.

Append blank fails.


Why? This has nothing that can be a problem. Can you explain what is the problem?
Here works ok.

Code (fw): Select all Collapse
STATIC FUNCTION ADO_APPEND( nWA, lUnLockAll )

   LOCAL oRecordSet := USRRDD_AREADATA( nWA )[ WA_RECORDSET ]
   LOCAL aWdata := USRRDD_AREADATA( nWA )
   
   HB_SYMBOL_UNUSED( lUnLockAll )

    oRecordSet:AddNew()
    oRecordSet:Update()
    
    IF !lUnlockAll
        ADO_UNLOCK(nWA)
    ENDIF   
    AADD(aWdata[ WA_LOCKLIST ],oRecordSet:BookMark)

   RETURN HB_SUCCESS
Regards

Antonio H Ferreira
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 08:46 AM
Code (fw): Select all Collapse
HB_FUNC( DBSETRELATION )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBRELINFO dbRelations;
      AREAP pChildArea;
      HB_AREANO uiChildArea;
      char * szAlias = NULL;

      if( hb_pcount() < 2 ||
          hb_param( 1, HB_IT_NUMERIC | HB_IT_STRING ) == NULL ||
          ! ( HB_ISNIL( 4 ) || HB_ISLOG( 4 ) ) )
      {
         hb_errRT_DBCMD( EG_ARG, EDBCMD_REL_BADPARAMETER, NULL, HB_ERR_FUNCNAME );
         return;
      }

      if( HB_ISNUM( 1 ) )
      {
         uiChildArea = ( HB_AREANO ) hb_parni( 1 );
      }
      else
      {
         int iArea = hb_rddGetCurrentWorkAreaNumber();

         hb_rddSelectWorkAreaAlias( hb_parcx( 1 ) );
         if( hb_vmRequestQuery() )
            return;
         uiChildArea = ( HB_AREANO ) hb_rddGetCurrentWorkAreaNumber();
         hb_rddSelectWorkAreaNumber( iArea );
      }

      pChildArea = uiChildArea ? ( AREAP ) hb_rddGetWorkAreaPointer( uiChildArea ) : NULL;

      if( ! pChildArea )
      {
         hb_errRT_BASE( EG_NOALIAS, EDBCMD_NOALIAS, NULL, szAlias, 0 );
         return;
      }

      dbRelations.itmCobExpr = hb_itemNew( hb_param( 2, HB_IT_BLOCK ) );
      dbRelations.abKey = hb_itemNew( hb_param( 3, HB_IT_STRING ) );
      dbRelations.isScoped = hb_parl( 4 );
      dbRelations.isOptimized = HB_FALSE;
      dbRelations.lpaChild = pChildArea;
      dbRelations.lpaParent = pArea;
      dbRelations.lpdbriNext = NULL;

      SELF_SETREL( pArea, &dbRelations );
   }
   else
      hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, HB_ERR_FUNCNAME );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 08:47 AM
Code (fw): Select all Collapse
static void hb_sxRollBackChild( AREAP pArea, PHB_ITEM pItem )
{
   LPDBRELINFO lpdbRelation = pArea->lpdbRelations;

   while( lpdbRelation )
   {
      if( SELF_INFO( lpdbRelation->lpaChild, DBI_ROLLBACK, pItem ) != HB_SUCCESS )
         break;
      hb_sxRollBackChild( lpdbRelation->lpaChild, pItem );
      lpdbRelation = lpdbRelation->lpdbriNext;
   }
}
regards, saludos

Antonio Linares
www.fivetechsoft.com