ADO RDD xHarbour

Re: ADO RDD xHarbour

Postby Antonio Linares » Thu Apr 02, 2015 8:47 am

Code: Select all  Expand view  RUN
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ADO RDD xHarbour

Postby Antonio Linares » Thu Apr 02, 2015 8:49 am

Antonio,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ADO RDD xHarbour

Postby AHF » 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
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby Antonio Linares » Thu Apr 02, 2015 12:49 pm

Antonio

Code: Select all  Expand view  RUN
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ADO RDD xHarbour

Postby Antonio Linares » Thu Apr 02, 2015 12:51 pm

Code: Select all  Expand view  RUN
#define SUPER_SKIP(w, l)                ((*(_SUPERTABLE(w))->skip)(w, l))
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 02, 2015 12:54 pm

Antonio Linares wrote:Antonio,

Code: Select all  Expand view  RUN
/*
 * 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: Select all  Expand view  RUN
#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
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 02, 2015 1:01 pm

Antonio Linares wrote:Antonio

Code: Select all  Expand view  RUN
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
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby Antonio Linares » Thu Apr 02, 2015 1:04 pm

Antonio,

Is not DbSelectArea() working by default ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 02, 2015 2: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
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Thu Apr 02, 2015 3:11 pm

Antonio,

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

Code: Select all  Expand view  RUN
  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.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 02, 2015 4: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
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Thu Apr 02, 2015 4: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.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby AHF » Thu Apr 02, 2015 5: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
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Thu Apr 02, 2015 6:03 pm

Antonio,

This picture shows the problem:

Image

There is only one record matching the filter cliteria:

set filter to Lugar = "Barcelona"

But Browse() works fine:

Image

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.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: ADO RDD xHarbour

Postby lucasdebeltran » Thu Apr 02, 2015 6: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: Select all  Expand view  RUN
  SELECT("LIBROS")
   LIBROS->(  dbgotop()  )

  ordsetfocus("LUCAS")



Code: Select all  Expand view  RUN
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.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

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