by AHF » Tue Mar 10, 2015 1:18 pm
Here it is
[code]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 := ADO_GETFIELDSIZE( ADO_GETFIELDTYPE( oRecordSet:Fields( nField - 1 ):Type ), oRecordSet:Fields( nField - 1 ):DefinedSize )
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 := oRecordSet:Fields( nField - 1 ):NumericScale
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