ADO RDD xHarbour

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

Re: ADO RDD xHarbour

Post by AHF »

Antonio,

Continue to get error UR_SUPER_ADDFIELD(0) EG_ARG 1003 SUBSSYSTEM ADORDD

May be I have a wrong version of UR_SUPER_ADDFIELD

What are the expected parameters of this function?

Also the THREAD STATIC does not compile I have to take THREAD out.

I dont have function hb_ntos, hb_stod

Without "common.ch" HB_SYMBOL_UNUSED does not compile.
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 »

In https://github.com/harbour/core/blob/ma ... rayrdd.prg UR_SUPER_ADDFIELD() is used this way:

Code: Select all

   FOR EACH aFieldStruct IN aStruct
      aField := Array( UR_FI_SIZE )
      aField[ UR_FI_NAME ]    := aFieldStruct[ DBS_NAME ]
      aField[ UR_FI_TYPE ]    := hb_Decode( aFieldStruct[ DBS_TYPE ], "C", HB_FT_STRING, "L", HB_FT_LOGICAL, "M", HB_FT_MEMO, "D", HB_FT_DATE, "N", iif( aFieldStruct[ DBS_DEC ] > 0, HB_FT_DOUBLE, HB_FT_INTEGER ) )
      aField[ UR_FI_TYPEEXT ] := 0
      aField[ UR_FI_LEN ]     := aFieldStruct[ DBS_LEN ]
      aField[ UR_FI_DEC ]     := aFieldStruct[ DBS_DEC ]
      UR_SUPER_ADDFIELD( nWA, aField )

   NEXT
nWA seems to be the workarea number and aField is an array with those values.
regards, saludos

Antonio Linares
www.fivetechsoft.com
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 »

I dont have function hb_ntos, hb_stod
Those functions are from harbour standard libraries.

How do you get this error ?
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,

Im working with FWH October 2008 and xHarbour Sept 2008 .

Is this the reason?
Regards
Antonio H Ferreira
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Antonio,

As far as I understand I must send in aField[ UR_FI_TYPE ] with clipper standard field types C N L...

But I still get te same error
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 »

Please post here the code that you are using when you fill aField and call the function
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 »

Here it is

Code: Select all

FOR n := 1 TO nTotalFields
      aField := Array( UR_FI_SIZE )
      aField[ UR_FI_NAME ] := oRecordSet:Fields( n - 1 ):Name
	  ADO_FIELDINFO( nWA, n, DBS_TYPE, @uInfo )
      aField[ UR_FI_TYPE ] := uInfo
      aField[ UR_FI_TYPEEXT ] := 0
	  ADO_FIELDINFO( nWA, n, DBS_LEN, @uInfo )
      aField[ UR_FI_LEN ]     := uInfo
	  ADO_FIELDINFO( nWA, n, DBS_DEC, @uInfo )
      aField[ UR_FI_DEC ]     := uInfo
/*
#ifdef UR_FI_FLAGS
      aField[ UR_FI_FLAGS ] := 0
#endif
#ifdef UR_FI_STEP
      aField[ UR_FI_STEP ] := 0
#endif
*/
MsgInfo( "name "+aField[ UR_FI_NAME ] +" Type "+ aField[ UR_FI_TYPE ] +" len "+str(aField[ UR_FI_LEN ])+" decimals "+str(aField[ UR_FI_DEC ] )  )

      UR_SUPER_ADDFIELD( nWA, aField )
   NEXT

STATIC FUNCTION ADO_FIELDINFO( nWA, nField, nInfoType, uInfo )

   LOCAL nType, nLen
   LOCAL oRecordSet := USRRDD_AREADATA( nWA )[ WA_RECORDSET ]

   DO CASE
   CASE nInfoType == DBS_NAME
      uInfo := oRecordSet:Fields( nField - 1 ):Name

   CASE nInfoType == DBS_TYPE
      nType := ADO_GETFIELDTYPE( oRecordSet:Fields( nField - 1 ):Type )
      DO CASE
      CASE nType == HB_FT_STRING
         uInfo := "C"
      CASE nType == HB_FT_LOGICAL
         uInfo := "L"
      CASE nType == HB_FT_MEMO
         uInfo := "M"
      CASE nType == HB_FT_OLE
         uInfo := "G"
#ifdef HB_FT_PICTURE
      CASE nType == HB_FT_PICTURE
         uInfo := "P"
#endif
      CASE nType == HB_FT_ANY
         uInfo := "V"
      CASE nType == HB_FT_DATE
         uInfo := "D"
#ifdef HB_FT_DATETIME
      CASE nType == HB_FT_DATETIME
         uInfo := "T"
#endif
      CASE nType == HB_FT_TIMESTAMP
         uInfo := "@"
      CASE nType == HB_FT_LONG
         uInfo := "N"
      CASE nType == HB_FT_INTEGER
         uInfo := "I"
      CASE nType == HB_FT_DOUBLE
         uInfo := "B"
      OTHERWISE
         uInfo := "U"
      ENDCASE

   CASE nInfoType == DBS_LEN
      ADO_FIELDINFO( nWA, nField, DBS_TYPE, @nType )
      IF nType == "N"
         nLen := oRecordSet:Fields( nField - 1 ):Precision
      ELSE
         nLen := [b]ADO_GETFIELDSIZE( ADO_GETFIELDTYPE( oRecordSet:Fields( nField - 1 ):Type ), oRecordSet:Fields( nField - 1 ):DefinedSize )[/b]
      ENDIF
      /* Un campo mayor de 1024 lo consideramos un campo memo */
      uInfo := iif( nLen > 1024, 10, nLen )

   CASE nInfoType == DBS_DEC
      ADO_FIELDINFO( nWA, nField, DBS_LEN, @nLen )
      ADO_FIELDINFO( nWA, nField, DBS_TYPE, @nType )
      IF oRecordSet:Fields( nField - 1 ):Type == adInteger
         uInfo := 0
      ELSEIF nType == "N"
         //uInfo := Min( Max( 0, nLen - 1 - oRecordSet:Fields( nField - 1 ):DefinedSize ), 15 )
		 [b]uInfo := oRecordSet:Fields( nField - 1 ):NumericScale[/b]
      ELSE
         uInfo := 0
      ENDIF
#ifdef DBS_FLAG
   CASE nInfoType == DBS_FLAG
      uInfo := 0
#endif
#ifdef DBS_STEP
   CASE nInfoType == DBS_STEP
      uInfo := 0
#endif
   OTHERWISE
      RETURN HB_FAILURE
   ENDCASE

   RETURN HB_SUCCESS


/[code]
Regards
Antonio H Ferreira
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Code: Select all

FOR n := 1 TO nTotalFields
aField := Array( UR_FI_SIZE )
aField[ UR_FI_NAME ] := oRecordSet:Fields( n - 1 ):Name
ADO_FIELDINFO( nWA, n, DBS_TYPE, @uInfo )
aField[ UR_FI_TYPE ] := uInfo
aField[ UR_FI_TYPEEXT ] := 0
ADO_FIELDINFO( nWA, n, DBS_LEN, @uInfo )
aField[ UR_FI_LEN ] := uInfo
ADO_FIELDINFO( nWA, n, DBS_DEC, @uInfo )
aField[ UR_FI_DEC ] := uInfo
/*
#ifdef UR_FI_FLAGS
aField[ UR_FI_FLAGS ] := 0
#endif
#ifdef UR_FI_STEP
aField[ UR_FI_STEP ] := 0
#endif
*/
MsgInfo( "name "+aField[ UR_FI_NAME ] +" Type "+ aField[ UR_FI_TYPE ] +" len "+str(aField[ UR_FI_LEN ])+" decimals "+str(aField[ UR_FI_DEC ] ) )

UR_SUPER_ADDFIELD( nWA, aField )
NEXT

STATIC FUNCTION ADO_FIELDINFO( nWA, nField, nInfoType, uInfo )

LOCAL nType, nLen
LOCAL oRecordSet := USRRDD_AREADATA( nWA )[ WA_RECORDSET ]

DO CASE
CASE nInfoType == DBS_NAME
uInfo := oRecordSet:Fields( nField - 1 ):Name

CASE nInfoType == DBS_TYPE
nType := ADO_GETFIELDTYPE( oRecordSet:Fields( nField - 1 ):Type )
DO CASE
CASE nType == HB_FT_STRING
uInfo := "C"
CASE nType == HB_FT_LOGICAL
uInfo := "L"
CASE nType == HB_FT_MEMO
uInfo := "M"
CASE nType == HB_FT_OLE
uInfo := "G"
#ifdef HB_FT_PICTURE
CASE nType == HB_FT_PICTURE
uInfo := "P"
#endif
CASE nType == HB_FT_ANY
uInfo := "V"
CASE nType == HB_FT_DATE
uInfo := "D"
#ifdef HB_FT_DATETIME
CASE nType == HB_FT_DATETIME
uInfo := "T"
#endif
CASE nType == HB_FT_TIMESTAMP
uInfo := "@"
CASE nType == HB_FT_LONG
uInfo := "N"
CASE nType == HB_FT_INTEGER
uInfo := "I"
CASE nType == HB_FT_DOUBLE
uInfo := "B"
OTHERWISE
uInfo := "U"
ENDCASE

CASE nInfoType == DBS_LEN
ADO_FIELDINFO( nWA, nField, DBS_TYPE, @nType )
IF nType == "N"
nLen := oRecordSet:Fields( nField - 1 ):Precision
ELSE
nLen := [b]ADO_GETFIELDSIZE( ADO_GETFIELDTYPE( oRecordSet:Fields( nField - 1 ):Type ), oRecordSet:Fields( nField - 1 ):DefinedSize )[/b]
ENDIF
/* Un campo mayor de 1024 lo consideramos un campo memo */
uInfo := iif( nLen > 1024, 10, nLen )

CASE nInfoType == DBS_DEC
ADO_FIELDINFO( nWA, nField, DBS_LEN, @nLen )
ADO_FIELDINFO( nWA, nField, DBS_TYPE, @nType )
IF oRecordSet:Fields( nField - 1 ):Type == adInteger
uInfo := 0
ELSEIF nType == "N"
//uInfo := Min( Max( 0, nLen - 1 - oRecordSet:Fields( nField - 1 ):DefinedSize ), 15 )
uInfo := [b]oRecordSet:Fields( nField - 1 ):NumericScale[/b]
ELSE
uInfo := 0
ENDIF
#ifdef DBS_FLAG
CASE nInfoType == DBS_FLAG
uInfo := 0
#endif
#ifdef DBS_STEP
CASE nInfoType == DBS_STEP
uInfo := 0
#endif
OTHERWISE
RETURN HB_FAILURE
ENDCASE

RETURN HB_SUCCESS


 
Regards
Antonio H Ferreira
User avatar
lucasdebeltran
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am
Contact:

Re: ADO RDD xHarbour

Post by lucasdebeltran »

Hello Antonio,

If you post a full working sample it would be easier to look into the problem.

I tested ADORDD in the past and it worked nice, but indexes were not supported. Are thet now?.
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.
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: ADO RDD xHarbour

Post by AHF »

Hello Lucas,

Im using the rddado.prg and .ch posted by Antonio in previous post.
I've proceed with the changes posted after because I always get an error .

I'm trying to work first with dbf files like this.

RddRegister("ADORDD",1)
RddSetDefault("ADORDD")

sele 0
use "whatever" shared

Browse()

I dont know if indexes work now. There is code for it but I still didnt tryed it.
It depends also on the provider.
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,

All that we can do here is to double check that we have properly filled aField before calling that function.

I doubt there is an error like this in the Harbour RDD engine, so I guess we are suplying wrong values to aField

If everything is ok, we may need to low level trace the RDD code to find the exact value that generates the error.
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,

I checked with msginfo() and the values in aField passed to UR_SUPER_ADDFIELD( nWA, aField ) are:

nWa = workarea number
aField[ UR_FI_NAME ] := "name of field"
aField[ UR_FI_TYPE ] := one of "C","L","D","N","M"
aField[ UR_FI_TYPEEXT ] := 0
aField[ UR_FI_LEN ] := length of the field as number
aField[ UR_FI_DEC ] := number of decimal places as number

aField array 5 elements

The first element shows:

nWA 20
NAME "NRENCOMEND"
TYPE "C"
LEN 10
DEC 0
TYPEEXT 0

and it generates the error.

In the original RDDADO the values were:

nWa 20
NAME "NRENCOMEND"
TYPE HB_FT_STRING
LEN 10
DEC 0
TYPEEXT 0

Same result.
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 »

Have you compared it with the way it is called from ?

https://github.com/harbour/core/blob/ma ... rayrdd.prg
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,

Yes and I checked with :

msginfo(str(HB_Decode( aField[ DBS_TYPE ], "C", HB_FT_STRING, "L", HB_FT_LOGICAL, "M", HB_FT_MEMO, "D", HB_FT_DATE, "N", IIF( aField[ DBS_DEC ] > 0, HB_FT_DOUBLE, HB_FT_INTEGER ) )))

It returns HB_FT_STRING for "C" for example.

All other elements are straight foward.

The error 1003 its a variable not found.

Can this be due for some other reason?
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 guess you have to supply HB_FT_STRING instead of "C"
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply