Mr. Rao - Error using BIT type with TRecSet Class - Ado

Mr. Rao - Error using BIT type with TRecSet Class - Ado

Postby Compuin » Sun Aug 21, 2022 5:12 pm

Hello Mr Rao

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

I do my Ado connection with this

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


Now I need to open a Table using this code

Code: Select all  Expand view
 
    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: Select all  Expand view
@ 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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1213
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: Mr. Rao - Error using BIT type with TRecSet Class - Ado

Postby nageswaragunupudi » Mon Aug 22, 2022 5:33 pm

I am looking into this.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao - Error using BIT type with TRecSet Class - Ado

Postby nageswaragunupudi » Mon Aug 22, 2022 5:34 pm

I am looking into this.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao - Error using BIT type with TRecSet Class - Ado

Postby nageswaragunupudi » Mon Aug 29, 2022 4:49 am

We tested and TReSet class deals with BIT fields properly.
BIT field needs to be defined like this:
Code: Select all  Expand view
`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: Select all  Expand view
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: Select all  Expand view

? 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
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 16 guests