ADO RDD xHarbour

Re: ADO RDD xHarbour

Postby AHF » Sat May 23, 2015 8:54 am

Lucas,

Mailed you last version.

cCondicion := "Dtoc( FIELD->FECHA ) >= " + chr( 34 ) + Dtoc( dFecha1 ) + chr( 34 ) + ;
" .AND. Dtoc( FIELD->FECHA ) <= " + chr( 34 ) + Dtoc( dFecha2 ) + chr( 34 )



SET FILTER TO alltrim( AUXILIAR->RELACION ) == alltrim( STR( oData:Codigo ))


cCondicion := "CONTA->CONCEPTO = " + chr( 34 ) + alltrim( cValToChar( cCuentaoConcepto ) ) + chr( 34 )


These should be ok since the are simply cleaned from expression because they are only conversion functions.

But when we use "extraction" functions like month etc I cant see how it can works because they are out of scope in :filter.
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby AHF » Sat May 23, 2015 9:01 am

Lucas,

No, the replace is as follows:

REPLACE FIELD->FECHA WITH Date().


Here with MySql it works so must be a configuration issue.

Here fielddate is:
FIELDDATE DATE NULL DEFAULT NULL;
All other options empty
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby AHF » Sat May 23, 2015 9:10 am

Lucas,

Your MySql innoDB ?
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Sat May 23, 2015 9:10 am

Antonio,

With the version you just send me, there are some bugs so far:

At, ADOFINDREC(), oRecordSet:AbsolutePosition := IF( oRS:AbsolutePosition == adPosEOF, oRS:RecordCount() + 1, oRS:AbsolutePosition ) is failing, as IF( oRS:AbsolutePosition == adPosEOF, oRS:RecordCount() + 1, oRS:AbsolutePosition ) its giving -1, which is not possible.

HBRECNO is not created by default. Also, the code at ADO_OPEN is not being proccessed to add it.

I suggested to simple add it to ADOCREATE(), which is the easiest way as explained before.

Also, to help debugging, please at AdoShowError, add procname(2) to 7:



Code: Select all  Expand view  RUN
FUNCTION ADOSHOWERROR( oCn, lSilent )

   LOCAL nErr, oErr, cErr

   DEFAULT oCn TO oConnection
   DEFAULT lSilent TO .F.

   IF ( nErr := oCn:Errors:Count ) > 0
      oErr  := oCn:Errors( nErr - 1 )
      IF ! lSilent
         WITH OBJECT oErr
            cErr     := oErr:Description
            cErr     += CRLF + 'Source       : ' + oErr:Source
            cErr     += CRLF + 'NativeError  : ' + cValToChar( oErr:NativeError )
            cErr     += CRLF + 'Error Source : ' + oErr:Source
            cErr     += CRLF + 'Sql State    : ' + oErr:SQLState
            cErr     += CRLF + REPLICATE( '-', 50 )
            cErr     += CRLF + PROCNAME( 1 ) + "( " + cValToChar( PROCLINE( 1 ) ) + " )"
            cErr     += CRLF + PROCNAME( 2 ) + "( " + cValToChar( PROCLINE( 2 ) ) + " )"
            cErr     += CRLF + PROCNAME( 3 ) + "( " + cValToChar( PROCLINE( 3 ) ) + " )"
            cErr     += CRLF + PROCNAME( 4 ) + "( " + cValToChar( PROCLINE( 4 ) ) + " )"
            cErr     += CRLF + PROCNAME( 5 ) + "( " + cValToChar( PROCLINE( 5 ) ) + " )"
            cErr     += CRLF + PROCNAME( 6 ) + "( " + cValToChar( PROCLINE( 6 ) ) + " )"
            cErr     += CRLF + PROCNAME( 7 ) + "( " + cValToChar( PROCLINE( 7 ) ) + " )"
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 » Sat May 23, 2015 9:19 am

Fix for HBRECNO creating:

Code: Select all  Expand view  RUN


STATIC FUNCTION ADO_CREATE( nWA, aOpenInfo  )

  LOCAL aWAData := USRRDD_AREADATA( nWA )
  LOCAL cTable  := hb_tokenGet( aOpenInfo[ UR_OI_NAME ], 1, ";" )
  LOCAL cDataBase  := hb_tokenGet( aOpenInfo[ UR_OI_NAME ], 2, ";" )
  LOCAL cDbEngine  := hb_tokenGet( aOpenInfo[ UR_OI_NAME ], 3, ";" )
  LOCAL cServer    := hb_tokenGet( aOpenInfo[ UR_OI_NAME ], 4, ";" )
  LOCAL cUserName  := hb_tokenGet( aOpenInfo[ UR_OI_NAME ], 5, ";" )
  LOCAL cPassword  := hb_tokenGet( aOpenInfo[ UR_OI_NAME ], 6, ";" )
  LOCAL cSql, cSql2, lAddAutoInc := .F.
  LOCAL oCatalog , cMarkTmp, lNoError := .T.,cTmpTable

   IF EMPTY(cDbEngine) //IF NOT DEFINED USE DEFAULT
      ADODEFAULTS()
   ENDIF

   IF( ALLTRIM( cDataBase ) == "" ,cDataBase:= t_cDataSource, cDataBase )
   IF( ALLTRIM( cTable ) == "" , cTable := aOpenInfo[ UR_OI_NAME ] ,cTable)
   IF( ALLTRIM( cDbEngine ) == "" ,cDbEngine:= t_cEngine, cDbEngine )
   IF( ALLTRIM( cServer ) == "" , cServer:= t_cServer, cServer )
   IF( ALLTRIM( cUserName ) == "" , cUserName:= t_cUserName, cUserName )
   IF( ALLTRIM( cPassword ) == "" , cPassword:= t_cPassword, cPassword )

    hb_adoSetDSource(cDataBase)
    hb_adoSetEngine( cDbEngine )
    hb_adoSetServer( cServer )
    hb_adoSetUser( cUserName )
    hb_adoSetPassword( cPassword )

   IF cDbEngine = "ACCESS" //t_cEngine WITH DEFAULT VALUE BU ADODEFAULTS
      IF !FILE(cDataBase)
         oCatalog    := TOleAuto():New( "ADOX.Catalog" )
         oCatalog:Create( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cDataBase )
      ENDIF
   ENDIF

   aOpenInfo[ UR_OI_NAME ] := CFILENOEXT( CFILENOPATH( cTable ) )

   ADOCONNECT( nWA, aOpenInfo )

   /*
   fix to add HBRECNO if it´s not present  // Lucas De Beltran 23.05.2015
   */

   if AScan( aWAData[ WA_SQLSTRUCT ], ADODEFLDRECNO() ) == 0
      AIns( aWAData[ WA_SQLSTRUCT ], 1, {  ADODEFLDRECNO(), '+', 10, 0 }, .t. )
   endif


   cSql := ADOSTRUCTTOSQL( aWAData, aWAData[ WA_SQLSTRUCT ],@lAddAutoInc )

 
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 » Sat May 23, 2015 9:27 am

Lucas,

Antonio,

With the version you just send me, there are some bugs so far:

At, ADOFINDREC(), oRecordSet:AbsolutePosition := IF( oRS:AbsolutePosition == adPosEOF, oRS:RecordCount() + 1, oRS:AbsolutePosition ) is failing, as IF( oRS:AbsolutePosition == adPosEOF, oRS:RecordCount() + 1, oRS:AbsolutePosition ) its giving -1, which is not possible.

HBRECNO is not created by default. Also, the code at ADO_OPEN is not being proccessed to add it.

I suggested to simple add it to ADOCREATE(), which is the easiest way as explained before.

Also, to help debugging, please at AdoShowError, add procname(2) to 7:



HBRECNO or equivalent is missing. Im going to take out that code and it simply errors stating missing field...

AbsolutePosition Positionenum
Constant
Value
Description
adPosBOF
-2
Indicates that the current record pointer is at BOF (that is, the BOF property is True).
adPosEOF
-3
Indicates that the current record pointer is at EOF (that is, the EOF property is True).
adPosUnknown
-1
Indicates that the Recordset is empty, the current position is unknown, or the provider does not support the AbsolutePage or AbsolutePosition property.


Please also check your MySql ODBC driver params.

ADD COLUMN I need to have it in ADO_OPEN. Our client upload the tables with copy to and tehn he expects when opening it to have the field created.
Ill put it also in ADO_CREATE
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Sat May 23, 2015 9:36 am

Antonio,

With my previous code for HBRECNO, ADOFINDREC() does not fail.


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 » Sat May 23, 2015 9:44 am

Antonio,

DbAppend(, ADO_APPEND(), fails with dates here:

Code: Select all  Expand view  RUN
           AADD( aVals, HB_DECODE( aStruct[ n, 2 ], 'C', Space( aStruct[ n, 3 ] ), 'D', CToD( '' ), 'L', .f., ;
                 'M', "", 'm', "", '+', 0, ;
                 'N', If( aStruct[ n, 3 ] == 0, 0, Val( "0." + Replicate( '0', aStruct[ n, 3 ] ) ) ), ;
                 'T', CTOT( '' ), '' ) )
 


It does not support an empty CTDOD().
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 » Sat May 23, 2015 10:17 am

Antonio,

I asked about empty dates at append blank.

Also, SET FILTER does not suport values, i.e:

Code: Select all  Expand view  RUN

SET FILTER TO LUCAS->NAME == cName
 


Thank you.

Seems less to finish ADORDD.
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 » Sat May 23, 2015 10:25 am

Lucas,

It does not support an empty CTDOD().


How can it work here like that? adordd its prepared to consider 31/12/1899 as empty date.
We place 31/12/1899?

With my previous code for HBRECNO, ADOFINDREC() does not fail.


Table is the same ? Here that version its working.

There must be something wrong with your config. Here all its working.

ADO_OPEN it inserts field set to be used as recno as first field primary key.

Do you have SET ADO DEFAULT RECNO FIELD TO .. defined?
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby AHF » Sat May 23, 2015 10:36 am

Lucas,

I asked about empty dates at append blank.


Please explain.

Also, SET FILTER does not suport values, i.e:

Code:

SET FILTER TO LUCAS->NAME == cName



Thats what I was speaking about. All vars must be evaluated before sent to ado filter once they are out of scope there.
In order to be 100 % compatible with standard syntax we must evaluate the filter condition ourselves and build a "faik" recordset.

Again please check your config because here all your mentioned points are working.
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Postby lucasdebeltran » Sat May 23, 2015 10:50 am

Antonio,

About filtering, is not possible at SqlTranslate() to evalutate cName, so as to get its value and build the filter?.
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 » Sat May 23, 2015 10:54 am

Antonio,

At ADOAPPEND(), and using Mr. Nages advice, this is the proper fix:

Code: Select all  Expand view  RUN


            AADD( aVals, HB_DECODE( aStruct[ n, 2 ], 'C', Space( aStruct[ n, 3 ] ), 'D', AdoNull(), 'L', .f., ;
                 'M', "", 'm', "", '+', 0, ;
                 'N', If( aStruct[ n, 3 ] == 0, 0, Val( "0." + Replicate( '0', aStruct[ n, 3 ] ) ) ), ;
                 'T', AdoNull(), '' ) )



 
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 » Sat May 23, 2015 12:19 pm

Antonio,

I get this error:


[0x80040E38][Microsoft Cursor Engine] Row cannot be located for updating. Some values may have been changed since it was last read

Error description: (DOS Error -2147352567) WINOLE/1007 No se puede encontrar la fila para su actualización: algunos valores han cambiado desde la última vez que se leyó. (0x80040E38): Microsoft Cursor Engine

Stack Calls
===========
Called from: => TOLEAUTO:UPDATE( 0 )
Called from: source\adordd.prg => ADO_PUTVALUE( 1503 )




ADO_PUTVALUE( 1503 ) -> oRecordSet:Update()

oRecordSet:Fields( nField - 1 ):Value := xValue
oRecordSet:Update()


This is my code:

REPLACE FACTURAS->NOMBRE WITH CLIENTES->NOMBRE
.... and so one


The real cause:

Field lengh for FACTURAS nombre is 34, but in CLIENTES is 50.
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 » Sat May 23, 2015 12:24 pm

But current NAME is LUCAS DE BELTRAN, not 50 or 34 chars.
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: No registered users and 92 guests