FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Xbrowse with field type time() in MYSQL
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM

Xbrowse with field type time() in MYSQL

Posted: Fri Feb 07, 2020 04:50 PM
Hello
I have a MySQL table with a field type time() ( I use Ado )

https://drive.google.com/file/d/1w85dTGdh8HasWiJfbggHCotneDcabXZH/view?usp=sharing



When I use with FW invece di avere 13:00:00 I have

https://drive.google.com/open?id=12yT0ssLDJSLocr_U2yof3-ar-3BMxoM1

it is possible to use this field in GET / XBROWSE ?



Thanks

Maurizio
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Xbrowse with field type time() in MYSQL

Posted: Thu Feb 13, 2020 03:21 AM
Can you please try this modification in fwh\source\function\adofuncs.prg and let us know the results?

Please locate the following lines in
function FWAdoFieldStruct( oRs, n, lExt, cDbms )
in
fwh\source\function\adofuncs.prg

Code (fw): Select all Collapse
   if nType == adBoolean
      cType    := 'L'
      nLen     := 1
   elseif AScan( { adDate, adDBDate, adDBTime, adDBTimeStamp }, nType ) > 0


Please change the above as:
Code (fw): Select all Collapse
   if nType == adBoolean
      cType    := 'L'
      nLen     := 1
   elseif nType == adDBTime
      cType    := "C"
      nLen     := 8
   elseif AScan( { adDate, adDBDate, adDBTimeStamp }, nType ) > 0


Can you please implement the change and let us know if we are getting the desired result?
Regards



G. N. Rao.

Hyderabad, India
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM

Re: Xbrowse with field type time() in MYSQL

Posted: Thu Feb 13, 2020 02:17 PM
Thanks Rao , but same problem

also now i have this error

Code (fw): Select all Collapse
 Time from start: 0 hours 0 mins 5 secs 
   Error occurred at: 13/02/2020, 15:13:45
   Error description: Error BASE/1100  Parametro errato: TRIM
   Args:
     [   1] = T   13/02/2020 08:30:00.000

Stack Calls
===========
   Called from:  => XHB_TRIM( 0 )
   Called from: C:\FWH_19\my_fw\datarow.PRG => TDATAROW:READADO( 783 )
   Called from: C:\FWH_19\my_fw\datarow.PRG => TDATAROW:LOAD( 240 )
   Called from: C:\FWH_19\my_fw\datarow.PRG => TDATAROW:NEW( 197 )
   Called from: Calendario_new.prg => APPUNTA:DLGPRENOTA( 2052 )
   Called from: Calendario_new.prg => APPUNTA:PRESSBUTTON( 1852 )
   Called from: Calendario_new.prg => (b)APPUNTA_PAINTBOOK( 1481 )


https://drive.google.com/file/d/1ESXbh49FFrrukp6xAmc5qoBqXelNeAoN/view?usp=sharing


Maurizio
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Xbrowse with field type time() in MYSQL

Posted: Sat Feb 15, 2020 03:57 PM
Please discard the changes.
Keep the original program of FWH as it is.

For the purpose of testing, we created a table "timefield" on our FWH demo server in the cloud.

This is the creation SQL

Code (fw): Select all Collapse
CREATE TABLE timefield (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(10),
  fdate DATE,
  fdatetime DATETIME,
  ftime TIME


When viewed with FWH built-in library the xbrowse is ok and is working as expected:



But the problem is with ADO.
(x)Harbour ADO reads the value of a Time field of MySql as a date time value.
This is not the issue with xbrowse or datarow. This is the issue with (x)Harbour ADO functionality

? oRs:Fields( "ftime" ):Value --> datetime value with some unknown date
? ValType( oRs:Fields( "ftime" ):Value ) --> "T"

Now what should xbrowse and datarow classes do?

We are thinking.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Xbrowse with field type time() in MYSQL

Posted: Tue Feb 18, 2020 09:32 AM
We have seen that (x)Harbour ADO reads and writes TIME type fields (adTime) as DateTime values but not as TimeStrings in the format HH:MM:SS.

But we prefer these values to be displayed, edited and saved as time strings as HH:MM:SS, in xbrowse, datarow and also with Gets.

For this purpose, we enhanced the classes TXBrowse, TDataRow and TGet, which will be available in the next version to be released.

Get:
Time-part of a datetime variable can be viewed and edited as a time string if the picture clause is specified as "HH:MM:SS".

Example:
Code (fw): Select all Collapse
tDateTime := DateTime()
@ r, c GET tDateTime PICTURE "HH:MM:SS" <other clauses>


In the case of xbrowse and the default dialog of datarow, no extra coding is required. This behavior is automatic in case of adTime fields.

Test:
Code (fw): Select all Collapse
   oCn   := FW_DemoDB( "ADO" )
   oRs   := FW_OpenRecordSet( oCn, "timefield" )
   XBROWSER oRs FASTEDIT
   oRs:Close()
   oCn:Close()


Regards



G. N. Rao.

Hyderabad, India
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM

Re: Xbrowse with field type time() in MYSQL

Posted: Tue Feb 18, 2020 11:27 AM

Thanks Nages
I try it when the relese arrives
Maurizio

Continue the discussion