ADO RDD xHarbour

AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Antonio,

What is this for ?

HB_SYMBOL_UNUSED( nWA )
Regards
Antonio H Ferreira
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: ADO RDD xHarbour

Post by Enrico Maria Giordano »

Antonio,
AHF wrote:Antonio,

What is this for ?

HB_SYMBOL_UNUSED( nWA )
To avoid unused variable warning.

EMG
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Enrico,

Thanks
Regards
Antonio H Ferreira
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Antonio,

Ive made some changes to the function FWAdo... because ws returning wrong types and n decimals.

These replaced the former functions in adordd ADOGETFIELDSIZE AND DOGETFIELDTYPE.

It seems to be correct but Im not sure.

Could you or someone check the code below for some bugs?

There are also some questions marks to answer if someone knows.

Code: Select all

STATIC FUNCTION ADO_FIELDSTRUCT( oRs, n ) // ( oRs, nFld ) where nFld is 1 based
                                    // ( oRs, oField ) or ( oRs, cFldName )
                                    // ( oField )

   LOCAL oField, nType, uval
   LOCAL cType := 'C', nLen := 10, nDec := 0, lRW := .t.,nDBFFieldType :=  HB_FT_STRING // default
   LOCAL nFWAdoMemoSizeThreshold := 1024
   
   /*
     cType DBF TYPE "C","N","D" ETC
     nDBFFieldType HB_FT_STRING ETC
   */
   /* IF n == nil
      oField      := oRs
      oRs         := nil
   ELSEIF VALTYPE( n ) == 'O'
      oField      := n
   ELSE
      IF ValType( n ) == 'N'
         n--
      ENDIF
      TRY
         oField      := oRs:Fields( n )
      CATCH
      END
   ENDIF
   IF oField == nil
      RETURN nil
   ENDIF
   */
   oField      := oRs:Fields( n )
   nType       := oField:Type

   IF nType == adBoolean
   
      cType    := 'L'
      nLen     := 1
      nDBFFieldType := HB_FT_LOGICAL
      
   ELSEIF ASCAN( { adDate, adDBDate, adDBTime, adDBTimeStamp }, nType ) > 0
   
      cType    := 'D'
      nLen     := 8
      IF oRs != nil .AND. ! oRs:Eof() .AND. VALTYPE( uVal := oField:Value ) == 'T' 
      //.AND. FW_TIMEPART( uVal ) >= 1.0 WHERE IS THIS FUNCTION?
         cType      := '@' //'T'
         nLen := oField:DefinedSize
         nDBFFieldType := HB_FT_TIMESTAMP // DONT KNWO IF IT IS CORRECT!
      ELSE
         nDBFFieldType := HB_FT_DATE
      ENDIF
      
   ELSEIF ASCAN( { adTinyInt, adSmallInt, adInteger, adBigInt, ;
                  adUnsignedTinyInt, adUnsignedSmallInt, adUnsignedInt, ;
                  adUnsignedBigInt }, nType ) > 0
                  
      cType    := 'N'
      nLen     := oField:Precision + 1  // added 1 for - symbol
      
      IF oField:Properties( "ISAUTOINCREMENT" ):Value == .t.
         cType := '+'
         lRW   := .f.
      ENDIF
      
      nDBFFieldType := HB_FT_INTEGER
      
   ELSEIF ASCAN( { adSingle, adDouble, adCurrency }, nType ) > 0
   
      cType    := 'N' //SHOULDNT BE "B"?
      nLen     := MIN( 19, oField:Precision-oField:NumericScale-1 ) //+ 2 )
      IF oField:NumericScale > 0 .AND. oField:NumericScale < nLen
         nDec  := oField:NumericScale
      ENDIF
      nDBFFieldType := HB_FT_INTEGER //HB_FT_DOUBLE WICH ONE IS CORRECT?
      
   ELSEIF ASCAN( { adDecimal, adNumeric, adVarNumeric }, nType ) > 0
   
      cType    := 'N'
      nLen     := Min( 19, oField:Precision-oField:NumericScale-1 ) //+ 2 )
      
      IF oField:NumericScale > 0 .AND. oField:NumericScale < nLen
         nDec  := oField:NumericScale
      ENDIF
      
      nDBFFieldType := HB_FT_INTEGER //HB_FT_LONG WICH ONE IS CORRECT?
      
   ELSEIF ASCAN( { adBSTR, adChar, adVarChar, adLongVarChar, adWChar, adVarWChar, adLongVarWChar }, nType ) > 0
   
      nLen     := oField:DefinedSize
      nDBFFieldType := HB_FT_STRING
      
      IF nType != adChar .AND. nType != adWChar .AND. nLen > nFWAdoMemoSizeThreshold
         cType := 'M'
         nLen  := 10
         nDBFFieldType := HB_FT_MEMO
      ENDIF
      
   ELSEIF ASCAN( { adBinary, adVarBinary, adLongVarBinary }, nType ) > 0
   
      cType := "G"
      nLen     := oField:DefinedSize
      IF nType != adBinary .AND. nLen > nFWAdoMemoSizeThreshold
         cType := 'M'
         nLen  := 10
      ENDIF
      
      nDBFFieldType := HB_FT_OLE
      
      IF nType != adBinary .AND. nLen > nFWAdoMemoSizeThreshold
         nDBFFieldType := HB_FT_MEMO
      ENDIF

   ELSEIF ASCAN( { adChapter, adPropVariant}, nType ) > 0
   
      cType    := 'O'
      lRW      := .f.
      nDBFFieldType := HB_FT_MEMO
      
   ELSEIF ASCAN( { adVariant, adIUnknown }, nType ) > 0 

      cType := "V"
      nDBFFieldType := HB_FT_ANY
      
   ELSEIF ASCAN( { adGUID }, nType ) > 0      
   
      nDBFFieldType := HB_FT_STRING
      
   ELSEIF ASCAN( { adFileTime }, nType ) > 0          
    
      cType := "T"  
      nDBFFieldType := HB_FT_DATETIME
      
   ELSEIF ASCAN( { adEmpty, adError, adUserDefined, adIDispatch  }, nType ) > 0   
   
      cType = 'O'
      lRw := .t.
      nDBFFieldType := HB_FT_NONE //what is this? maybe NONE is wrong!
      
   ELSE
   
      lRW      := .f.
      
   ENDIF
   
   IF lAnd( oField:Attributes, 0x72100 ) .OR. ! lAnd( oField:Attributes, 8 )
      lRW      := .f.
   ENDIF
   
   RETURN { oField:Name, cType, nLen, nDec, nType, lRW, nDBFFieldType }

 
Regards
Antonio H Ferreira
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: ADO RDD xHarbour

Post by Antonio Linares »

Antonio,

I am afraid that the only way to really test it is once it becomes used by several Harbour/xharbour users
regards, saludos

Antonio Linares
www.fivetechsoft.com
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Antonio,

What I dont understad is what type of fields we must return to SUPER!
Is it only STRING, DATE, LOGICAL, DOUBLE OR INTEGER as in arrayrdd?

Im now taking care of :Seek but I need to use DB indexes. Seek cannot be translated to :Find as :Find only works on a single column.

Do you code code use index present in the server DB with ADOX? Maybe Enrico has it.

Im only missing this to close the first part of adodrdd

I hope to post during week end the adordd.
Regards
Antonio H Ferreira
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: ADO RDD xHarbour

Post by Antonio Linares »

Antonio,

Yes, you can only return the types that Harbour supports.

What if you issue a new SELECT clause with the WHERE conditions that you are searching for ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: ADO RDD xHarbour

Post by Enrico Maria Giordano »

Antonio,
AHF wrote:Do you code code use index present in the server DB with ADOX? Maybe Enrico has it.
No, I prefer to use WHERE and ORDER BY clauses.

EMG
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Antonio, Enrico,

I know I shouldnt use ADOX!
I agree is the best practice. Indexes are for the DB admin to deliver selects rapidly.

But dont forget that what we pretend is to change as little code as possible in our app.

I could use seek but then I would have to call a resetseek() to come back to the previous select. Doesnt seems a huge work.
But if I need to add blanck recs to the select to come back later for update I would not found them because they still dont fill the select where clause.This is a problem! Maybe using a diferent cursor?

Do you have any idea how to workaround this?
Regards
Antonio H Ferreira
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: ADO RDD xHarbour

Post by Enrico Maria Giordano »

Antonio,
AHF wrote:I know I shouldnt use ADOX!
Please note that ADOX is only supported by Microsoft databases.

EMG
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Enrico,

Forgot ADOX going into SELECT.
Regards
Antonio H Ferreira
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: ADO RDD xHarbour

Post by Antonio Linares »

Use oRs:Filter instead of WHERE, so setting oRs:Filter := "" will make have you have all of them when you need them
regards, saludos

Antonio Linares
www.fivetechsoft.com
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Antonio,

Thanks but it seems filter its not advisable and compatible with all providers.

Ill give a try with selects
Regards
Antonio H Ferreira
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Antonio,

In ADO_OPEN we load all fieldinfo UR_SUPER_ADDFIELD( nWA, aField ).

How can we get back after the information save there?
Regards
Antonio H Ferreira
Post Reply