Hi,
This function with DateTime fields wrongly retrieves such field type as D, but should be T in Access.
Thank you.
FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Hi,
This function with DateTime fields wrongly retrieves such field type as D, but should be T in Access.
Thank you.
function FieldTypeAdoToDbf( nType ) fails too, in Access and MYSQL.
MOISES wrote:Hi,
but should be T in Access.
The field is defined in Access as DateTime, but if it only stores a date FWAdoFieldType returns D.
If it also has date and time, FWAdoFieldType returns T.
FieldTypeAdoToDbf fails alwawys.
Any clue please?
Thank you.
dDate := oRs:Fields("Date"):Value // assumes the ado field type = DateTime
cType := Valtype( dDate )
MsgInfo( cType )
cType should = TNo, it returns "D", when the field is empty or has a date only.
"T" is returned when the field has a datetime inside.
Thank you,
MOISES wrote:Hi,
This function with DateTime fields wrongly retrieves such field type as D, but should be T in Access.
Thank you.
Thank you for your time.
So, how can I get the field type as "T", irrespective of if its empty or full?
Up, thank you.
Any clue please?
Thank you.
Can we see a reduced and self-contained sample (database included) showing the problem, please?
EMG
#include "fivewin.ch"
#include "adodef.ch"
static oCn
static cTable := "test_datetime"
//----------------------------------------------------------------------------//
function Main()
SetGetColorFocus()
FWNumFormat( "A", .t. )
oCn := FW_OpenAdoConnection( "xbrtest.mdb" )
if oCn == nil
? "Connect Fail"
return nil
endif
if .not. FW_AdoTableExists( cTable, oCn ) .or. ;
MsgYesNo( "Create Table again?" )
CreateTestTable()
endif
EditTable()
oCn:Close()
return nil
//----------------------------------------------------------------------------//
function CreateTestTable()
local aCols := { { "ITEM", "C", 10, 0 }, { "PRICE", "N", 12, 2 }, { "DATETIME", "T", 10, 0 }, { "DESCRIPTION", "C", 20, 0 } }
local oRs
? "Creating Table"
if FW_AdoTableExists( cTable, oCn )
oCn:Execute( "DROP TABLE " + cTable )
endif
FWAdoCreateTable( cTable, aCols, oCn )
return nil
//----------------------------------------------------------------------------//
function EditTable()
local oRs
local oDlg, oFont, oBrw
local nAppendRec := nil
local aStruct := {}
local nField := 0
local csql
oRs := FW_OpenRecordSet( oCn, cTable, adLockBatchOptimistic )
aStruct := FWAdoStruct( oRs )
nField := AScan( aStruct, {|a| Upper(a[1]) == "DATETIME" } )
cSQL := FWAdoFieldType( oRs, nField )
?cSQL
xbrowser ors fastedit
oRs:Close()
return nil
//----------------------------------------------------------------------------//I get "Connect Fail".
EMG
Ok, I got xbrtest.mdb from FWH samples.
EMG