FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Mr. Rao - Error using BIT type with TRecSet Class - Ado
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Mr. Rao - Error using BIT type with TRecSet Class - Ado
Posted: Sun Aug 21, 2022 05:12 PM
Hello Mr Rao

I'm trying to get acces to a table using ADO.

I do my Ado connection with this

Code (fw): Select all Collapse
oAp:oMySql:= FW_OpenAdoConnection( { "MYSQL", cServer, cDataBase, cUser, cPassWord }, .t. )


Now I need to open a Table using this code

Code (fw): Select all Collapse
   
    cSql:= "SELECT * FROM CUSTOMER"
  
    oTable:=TRecSet():New():Open( cSql, oAp:oMySql )


For this line, I need to retrieve a Logical field, I set this field as BIT

Code (fw): Select all Collapse
@ 5.7, 22 CHECKBOX oTable:Married PROMPT "Married"  UPDATE OF oDlg     //Line 51


But not matter if I switch BIT or TINYINT, I always get this error message
Time from start: 0 hours 0 mins 16 secs
Error occurred at: 21/08/2022, 13:06:04
Error description: Error BASE/1070 Argument error: ==
Args:
[ 1] = L .F.
[ 2] = N 1

Stack Calls
===========
Called from: .\source\classes\TRECSET.PRG => TRECSET:FIELDPUT( 596 )
Called from: .\source\classes\TRECSET.PRG => TRECSET:_MARRIED( 1286 )
Called from: source\Core\Ventas\test.prg => (b)TEST( 51 )


Please advise and thanks in advance

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Mr. Rao - Error using BIT type with TRecSet Class - Ado
Posted: Mon Aug 22, 2022 05:33 PM

I am looking into this.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Mr. Rao - Error using BIT type with TRecSet Class - Ado
Posted: Mon Aug 22, 2022 05:34 PM

I am looking into this.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Mr. Rao - Error using BIT type with TRecSet Class - Ado
Posted: Mon Aug 29, 2022 04:49 AM
We tested and TReSet class deals with BIT fields properly.
BIT field needs to be defined like this:
Code (fw): Select all Collapse
`MARRIED` bit(1) DEFAULT b'0',


ADO always treats BIT fields as Boolean values ( Type 11 adBoolean ).

ADO does not natively support treating TINYINT as LOGICAL. If we want, we need to handle this by ourselves in our application program.

Please test with this sample program. Please use the same server we used in this sample.
Code (fw): Select all Collapse
function AdoTestLogical()

   local oCn, oRs

   oCn   := FW_OpenAdoConnection( { "MYSQL","209.250.245.152","fwh","fwhuser","FiveTech@2022" }, .t. )

   if oCn == nil
      ? "connect fail"
      return nil
   endif

   oRs   := TRecSet():New( nil, "select * from customer", oCn )
   oRs:Open()
   if oRs:IsOpen

      ? oRs:Married, ValType( oRs:Married )
      oRs:Married := !oRs:Married
      ? oRs:Married

      oRs:Close()

   else
      ? "recset not open"
   endif

   oCn:Close()

return nil


You can comfortably use the value "oRs:bitfield" in CheckBoxes.
Please test
Code (fw): Select all Collapse
? oRs:FieldType( "married" ) // --> result should be "L"

to make sure.

TINYINT
ADO treats "adTinyInt" (16) as Numeric Integer but not as Logical.

We know some MySql programmers use TinyInt for logical values.
In the next version we will provide the option to the programmer for using TinyInt as logical.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion