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: Thu Apr 02, 2015 08:47 AM
Code (fw): Select all Collapse
static HB_ERRCODE hb_rddCloseParentRel( AREAP pArea, void * pChildArea )
{
   if( pArea->lpdbRelations )
   {
      LPDBRELINFO * lpdbRelationPtr = &pArea->lpdbRelations;
      HB_USHORT uiArea = ( ( AREAP ) pChildArea )->uiArea;

      do
      {
         LPDBRELINFO lpdbRelation = *lpdbRelationPtr;

         if( lpdbRelation->lpaChild->uiArea == uiArea )
         {
            /* Clear this relation */
            hb_rddSelectWorkAreaNumber( lpdbRelation->lpaChild->uiArea );
            SELF_CHILDEND( lpdbRelation->lpaChild, lpdbRelation );
            if( lpdbRelation->itmCobExpr )
               hb_itemRelease( lpdbRelation->itmCobExpr );
            if( lpdbRelation->abKey )
               hb_itemRelease( lpdbRelation->abKey );

            *lpdbRelationPtr = lpdbRelation->lpdbriNext;
            hb_xfree( lpdbRelation );
         }
         else
            lpdbRelationPtr = &lpdbRelation->lpdbriNext;
      }
      while( *lpdbRelationPtr );
   }
   return HB_SUCCESS;
}
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:49 AM

Antonio,

In the file c:\harbour\src\rdd\workarea.c it is used many times

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 12:39 PM
Antonio,

Thanks for the info

Relations are almost finished but I have still some questions about skips

In xHarbour help is mentioned:
Networking: Use SKIP 0 to make changes to a record visible to other work stations while a record is locked.


This also means that relation should be enforce in this case?
Is Habour the same?

Ive made relations in this way:

If field related is only one :find in childs

Otherwise Select in childs where field1 = and field2 =

To avoid so many calls Im trying to save the last key and if the next its the same doesnt do anything.
Can I use UR_RI_NEXT for this?
Regards

Antonio H Ferreira
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 12:49 PM
Antonio

Code (fw): Select all Collapse
static HB_ERRCODE hb_dbfSkip( DBFAREAP pArea, HB_LONG lToSkip )
{
   HB_ERRCODE errCode;

   HB_TRACE( HB_TR_DEBUG, ( "hb_dbfSkip(%p, %ld)", pArea, lToSkip ) );

   if( pArea->lpdbPendingRel )
   {
      if( SELF_FORCEREL( &pArea->area ) != HB_SUCCESS )
         return HB_FAILURE;
   }

   pArea->area.fTop = pArea->area.fBottom = HB_FALSE;

   if( lToSkip == 0 || pArea->area.dbfi.itmCobExpr || pArea->area.dbfi.fFilter ||
       hb_setGetDeleted() )
      return SUPER_SKIP( &pArea->area, lToSkip );

   errCode = SELF_SKIPRAW( &pArea->area, lToSkip );

   /* TODO: remove this hack - it's not necessary if SKIPRAW works
      as it should, Druzus */

   /* Move first record and set Bof flag */
   if( errCode == HB_SUCCESS && pArea->area.fBof && lToSkip < 0 )
   {
      errCode = SELF_GOTOP( &pArea->area );
      pArea->area.fBof = HB_TRUE;
   }

   /* Update Bof and Eof flags */
   if( lToSkip < 0 )
      pArea->area.fEof = HB_FALSE;
   else /* if( lToSkip > 0 ) */
      pArea->area.fBof = HB_FALSE;

   return errCode;
}
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 12:51 PM
Code (fw): Select all Collapse
#define SUPER_SKIP(w, l)                ((*(_SUPERTABLE(w))->skip)(w, l))
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 12:54 PM
Antonio Linares wrote: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 )


How can I catch it in adordd?

This is important because if we have a rel child area with a select where ... when leave parent area and we select the child area we should bring it to the default select to be able to skip freely through a莽莽 records otherwise only child records from parent can be skipped!
Regards

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

Code (fw): Select all Collapse
static HB_ERRCODE hb_dbfSkip( DBFAREAP pArea, HB_LONG lToSkip )
{
聽 聽HB_ERRCODE errCode;

聽 聽HB_TRACE( HB_TR_DEBUG, ( "hb_dbfSkip(%p, %ld)", pArea, lToSkip ) );

聽 聽if( pArea->lpdbPendingRel )
聽 聽{
聽 聽 聽 if( SELF_FORCEREL( &pArea->area ) != HB_SUCCESS )
聽 聽 聽 聽 聽return HB_FAILURE;
聽 聽}

聽 聽pArea->area.fTop = pArea->area.fBottom = HB_FALSE;

聽 聽if( lToSkip == 0 || pArea->area.dbfi.itmCobExpr || pArea->area.dbfi.fFilter ||
聽 聽 聽 聽hb_setGetDeleted() )
聽 聽 聽 return SUPER_SKIP( &pArea->area, lToSkip );

聽 聽errCode = SELF_SKIPRAW( &pArea->area, lToSkip );

聽 聽/* TODO: remove this hack - it's not necessary if SKIPRAW works
聽 聽 聽 as it should, Druzus */

聽 聽/* Move first record and set Bof flag */
聽 聽if( errCode == HB_SUCCESS && pArea->area.fBof && lToSkip < 0 )
聽 聽{
聽 聽 聽 errCode = SELF_GOTOP( &pArea->area );
聽 聽 聽 pArea->area.fBof = HB_TRUE;
聽 聽}

聽 聽/* Update Bof and Eof flags */
聽 聽if( lToSkip < 0 )
聽 聽 聽 pArea->area.fEof = HB_FALSE;
聽 聽else /* if( lToSkip > 0 ) */
聽 聽 聽 pArea->area.fBof = HB_FALSE;

聽 聽return errCode;
}


What is the diference between skip and skipraw?
The relation is enforced before the actual parent skip?

Can you explain the flow of it?
Regards

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

Antonio,

Is not DbSelectArea() working by default ?

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 02:04 PM
Antonio Linares wrote:Antonio,

Is not DbSelectArea() working by default ?


What do you mean?

What I pretend is to know adordd function is called by it and how can I check if the new selected area is present as child in some relation to reset it to default select..
Regards

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

For appending and browsing, Recordset should be opened at STATIC FUNCTION ADO_OPEN( nWA, aOpenInfo ) as shown:

Code (fw): Select all Collapse
   oRecordSet:CursorLocation := adUseClient //its slower but has avntages such always bookmaks
   oRecordSet:LockType := adLockOptimistic



Also, for appending blank, at STATIC FUNCTION ADO_APPEND( nWA, lUnLockAll ), I removed oRecordSet:Update(). Otherwise, it failed.


Mr. Nages would provide more insight than me. But sorce\function\adofuncs.prg show how to deal with ADO safely.

I use Mr. Nages ADO routines at production with no trouble at all.

What RBDMS are you using with your ADORDD.PRG?.
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: Thu Apr 02, 2015 04:16 PM

Lucas,

Regarding cursortype it will be altered after to give the chance to the programer to decide what to use when opening the table.
The adLockPessimistic setting is not supported if the CursorLocation property is set to adUseClient wich might be a problem.

I notice that we need to call :addnew always with fields and values (in blank) and I think then we will not get any more errors.

ADS Probably already next week will try it in real world with MySql and Oracle.

I hope to post today new adordd with relations ready.

Are you trying it with the array of indexes?

Thanks for your feed back

Regards

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

Antonio,

I advise you to start using asap Access and review adofuncs.prg. Once you had it working with Access, you can easily jump on MSSQL or MySQL, just changing connection strings. I followed that scheme when coding starting from 0 an application using Mr. Nages routines and TDataRow() class, and all went perfect.

No, I haven麓t tried indexes already, as to fully test a complete application I need LOCATE FOR, DbSeek(), SET FILTER and OrdSetFocus() to be working, and I think they are not ready yet.

Thank you for your work. Now with latest changes I could issue xBrowse(), but if I set a filter before a blank row is added at top, and also I get some runtime errors with xBrowse when navegating:

Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:GODOWN( 2975 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:KEYDOWN( 2318 )

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: Thu Apr 02, 2015 05:04 PM
Lucas,

No, I haven麓t tried indexes already, as to fully test a complete application I need LOCATE FOR, DbSeek(), SET FILTER and OrdSetFocus() to be working, and I think they are not ready yet.


All should be working (check index array) but Ill post in the next hour a new version of adordd already with relations.
Set filter I didnt do anything with it but should work. Check ADO_SETFILTER.

Ill give a try with Access.

I dont use xBrowse in this app but could you be more specific:

but if I set a filter before a blank row is added at top, and also I get some runtime errors with xBrowse when navegating


Is the table empty?
Can you find what is causing the error?
Is the filter expression compatible with what the actual ADO_SETFILTER can do?
Is it a adordd open recset error?

Thanks for your help
Regards

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

This picture shows the problem:



There is only one record matching the filter cliteria:

set filter to Lugar = "Barcelona"

But Browse() works fine:



So seems to be a problem with xBrowse麓s class and ::BookMark.

Have you tested LOCATE FOR and Seek?.

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: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: ADO RDD xHarbour
Posted: Thu Apr 02, 2015 06:24 PM
Hello,

Indexes are failing:

Error description: Error BASE/1132 Error de rango: acceso al array
Args:
[ 1] = A { ... } length: 0
[ 2] = N 0

At, ADO_ORDLSTFOCUS( 1135 ):

here: aOrderInfo[ UR_ORI_RESULT ] := aWAData[ WA_INDEXES ] [aWAData[ WA_INDEXACTIVE ]]
aWAData[ WA_INDEXACTIVE ] := n

ELSE

My code:

Code (fw): Select all Collapse
   SELECT("LIBROS")
   LIBROS->(  dbgotop()  )

  ordsetfocus("LUCAS")



Code (fw): Select all Collapse
at FUNCTION ListIndex(nOption)

LOCAL  Alista_fic:= { {"CCLIENTE",{"COD_CLI","CODCLIENTE"},;
 {"LIBROS", {"LUCAS", "PAIS"},;
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.