Page 12 of 70

Re: ADO RDD xHarbour

PostPosted: Fri Mar 27, 2015 10:18 pm
by Antonio Linares
Antonio,

UR_FIELDINFO ?

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 7:48 am
by AHF
Antonio,

Thanks its solved.

I need this hb_SToD() What does it do and were can I find it?

Can you post the source?

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 7:53 am
by AHF
Antonio,

Antonio Linares wrote:Antonio,

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


Are these all the types supported by (x)Harbour?

Code: Select all  Expand view

/* FIELD types */
#ifndef HB_FT_NONE
#define HB_FT_NONE            0
#define HB_FT_STRING          1     /* "C" */
#define HB_FT_LOGICAL         2     /* "L" */
#define HB_FT_DATE            3     /* "D" */
#define HB_FT_LONG            4     /* "N" */
#define HB_FT_FLOAT           5     /* "F" */
#define HB_FT_INTEGER         6     /* "I" */
#define HB_FT_DOUBLE          7     /* "B" */
#define HB_FT_TIME            8     /* "T" */
#define HB_FT_TIMESTAMP       9     /* "@" */
#define HB_FT_MODTIME         10    /* "=" */
#define HB_FT_ROWVER          11    /* "^" */
#define HB_FT_AUTOINC         12    /* "+" */
#define HB_FT_CURRENCY        13    /* "Y" */
#define HB_FT_CURDOUBLE       14    /* "Z" */
#define HB_FT_VARLENGTH       15    /* "Q" */
#define HB_FT_MEMO            16    /* "M" */
#define HB_FT_ANY             17    /* "V" */
#define HB_FT_IMAGE           18    /* "P" */
#define HB_FT_BLOB            19    /* "W" */
#define HB_FT_OLE             20    /* "G" */
#endif
 

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 8:16 am
by Antonio Linares
Those types are in Harbour hbusrrdd.ch so I guess yes, not sure if xHarbour is exactly the same

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 9:27 am
by AHF
Antonio,

Ok Im using those. Cross my fingers!

How to use SQL CONVERT to convert expressions like dtos(ddate)+val(ndays) ?

Does anyone has a CH file with all defs for CONVERT ?

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 11:17 am
by AHF
Antonio,Enrico,

Do you know What is the corresponding SQL SELECT ... CONVERT to dtos()?

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 11:40 am
by Enrico Maria Giordano
Antonio,

AHF wrote:Do you know What is the corresponding SQL SELECT ... CONVERT to dtos()?


Code: Select all  Expand view
SELECT * FROM table WHERE date = '20150328'


EMG

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 12:51 pm
by AHF
Enrico,

Thanks but my question was not clear

This is to be used in :find expression and I get this error.

Args:
[ 1] = C DATAFACTUR LIKE '20140407'
argumentos { DATAFACTUR LIKE '20140407' }
descrição DISP_E_UNKNOWNNAME
ficheiro <nenhuma>
genCode 41: Unknown or reserved
operação FIND
osCode (Não é erro do sistema operativo)
severity 2
subCode 6
subSystem ADODB.Recordset
tries 0

Can :find look for date like that ?

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 1:03 pm
by Antonio Linares
Antonio,

https://msdn.microsoft.com/en-us/library/windows/desktop/ms676117%28v=vs.85%29.aspx

It seems that this format is needed:

DATAFACTUR = #7/22/97#

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 1:11 pm
by Enrico Maria Giordano
Antonio,

AHF wrote:DATAFACTUR LIKE '20140407'


Try with:

DATAFACTUR = '20140407'

If you are using MDB try this instead:

Code: Select all  Expand view
DATAFACTUR = #04072014#


(DD/MM/YYYY)

EMG

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 4:06 pm
by AHF
Antonio, Enrico,

:Find with '20150327' or "20150327" and #20150327# doesnt work always same error.

:Find with 27/03/15 works in all above cases.

I could make a function

Code: Select all  Expand view


FUNCTION ADODTOS(dDate)

  IF RDDSETDEFAULT() = "ADORDD"

      RETURN DTOC(dDate)

  ENDIF

  RETURN DTOS(dDate)
 
 


and replace in code dtos with adodtos.

But a more clean approach was to redesign the original DTOS to cover this.

What is your opinion?

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 4:11 pm
by AHF
Antonio,

In ADO_GETVALUE there is a function hb_stod I dont know why!

Should I use stod

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 4:46 pm
by AHF
Decided different approach. What do you think?

Code: Select all  Expand view

STATIC FUNCTION ADODTOS(xDate)
 LOCAL dDate ,cYear,cMonth,cDay

   IF "." IN xDate .OR. "-" IN xDate .OR. "/" IN xDate
       dDate := xDate
   ELSE
        cYear  := SUBSTR(xDate,1,4)
    cMonth := SUBSTR(xDate,5,2)
    cDay   := SUBSTR(xDate,7,2)
    dDate  := CTOD(cDay+"/"+cMonth+"/"+cYear)
   ENDIF
   
   RETURN DTOC(dDate)
 

Re: ADO RDD xHarbour

PostPosted: Sat Mar 28, 2015 9:40 pm
by Antonio Linares
Antonio,

If it works then keep going, later on we can always modify it :-)

Re: ADO RDD xHarbour

PostPosted: Sun Mar 29, 2015 8:29 am
by nageswaragunupudi
Different date literal formats work with different SQL databases and also depending on settings.

Interestingly American dateformats work with many, because all the software is written by programmers (whatever be their nationality) sitting in USA. But we better stick to international formats.

But the following formats always work irrespective of locale, wherever in the world, and irrespective of locale settings:

Oracle:
WHERE DATEFLD = DATE 'YYYY-MM-DD'

MsSql, MySql and many others

WHERE DATEFLD = 'YYYY-MM-DD'

MSAccess

WHERE DATEFLD = #YYYY-MM-DD#

For ADO FILTERS, irrespective of the datasource.

oRs:Filter = "DATEFLD = #YYYY-MM-DD#"

Note:
1) I know may alternative formats which work with different databases. But here I gave those that work for sure and simple to make.
2) FW_DateToADO() and FW_DateToSQL() may be referred to in the adofuncs.prg