Page 1 of 2

Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Wed Feb 04, 2009 1:15 pm
by JC
Dear Antonio,

I found a erroneous conversion type in ADO->boolean to xBrowse->logical
ADO returns for xHarbour, for boolean fields, a numeric type. With this, I can't use the setCheck() method on xBrowse.
Please, it's possible for you to solve this problem? I can do it by myself?

Thank you very much!

Re: Erroneous type in ADO->boolean to xBrowse->logical

Posted: Wed Feb 04, 2009 2:38 pm
by JC
A little sample just for understanding

Into my object RecordSet... in this construction, I use the boolean type in :fields:append( "Active", adBoolean,, adFldUpdatable )... but, when the recordset is filled by any query into MySQL, the boolean field is interpreted like adTinyInt and this return 0 or 1 (not .T. or .F.)

Code: Select all

WITH OBJECT oRecordSet

     :fields:append( "Code", adInteger, 5, adFldUpdatable )
     :fields:append( "name", adVarChar, 30, adFldUpdatable )
     :fields:append( "Active", adBoolean,, adFldUpdatable )
     :fields:append( "Reg Date", adDate,, adFldUpdatable )

     TRY

        :open()
        
        :addNew()
        :fields( "Code" ):value := 1
        :fields( "name" ):value := "JÚLIO CÉSAR M. FERREIRA"
        :fields( "Active" ):value := .T.
        :fields( "Reg Date" ):value := date()

        :addNew()
        :fields( "Code" ):value := 2
        :fields( "name" ):value := "NEW USER FOR TESTS"
        :fields( "Active" ):value := .F.
        :fields( "Reg Date" ):value := date()

        :addNew()
        :fields( "Code" ):value := 3
        :fields( "name" ):value := "ANOTHER NEW USER FOR TESTS"
        :fields( "Active" ):value := .F.
        :fields( "Reg Date" ):value := date()

        :addNew()
        :fields( "Code" ):value := 4
        :fields( "name" ):value := "MORE ONE USER"
        :fields( "Active" ):value := .T.
        :fields( "Reg Date" ):value := date()

        :moveFirst()

END
Into my object xBrowse

Code: Select all

   WITH OBJECT oBrw

        :bClrRowFocus        := {|| { CLR_BLACK, nrgb( 228, 232, 224 ) } }
        :bClrSel             := {|| { , nrgb( 228, 232, 224 ) } }
        :nMarqueeStyle       := 4
        :nRowDividerStyle    := 4
        :nColDividerStyle    := 4
        :lColDividerComplete := .F.
        :nStretchCol         := STRETCHCOL_WIDEST

        :createFromCode()
        //:bLDblClick( {|| oRecordSet:fields( "Active" ):value := !oRecordSet:fields( "Active" ):value, oBrw:refresh() } )

        WITH OBJECT :aCols[3]

             :setCheck( { "GREEN", "RED" },  {|| msgInfo( oRecordSet:fields( "Active" ):value ) } )
             :setCheck( { "GREEN", "RED" }, {|o, v| ( oRecordSet:fields( "Active" ):value := v, msgInfo( oRecordSet:fields( "Active" ):value ) ) } )
             :bStrData        := {|| If( oRecordSet:fields( "Active" ):value, "Yes", "No" ) }
             :nDataStrAlign   := AL_RIGHT

        END

   END

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Wed Feb 04, 2009 6:02 pm
by JC
Sorry,

Still have error :(

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Fri Feb 06, 2009 12:39 pm
by JC
Please, someone knows?

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Fri Feb 06, 2009 2:31 pm
by Enrico Maria Giordano
Better starting with a reduced and self-contained sample of the problem. :wink:

EMG

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Fri Feb 06, 2009 6:46 pm
by JC
Enrico Maria Giordano wrote:Better starting with a reduced and self-contained sample of the problem. :wink:

EMG
I will provider it now!

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Fri Feb 06, 2009 7:03 pm
by JC
The self-contained sample with source:

http://rapidshare.com/files/194811022/ADO.zip.html

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Mon Feb 09, 2009 1:50 pm
by JC
Dear friends,

Please, somebody can help me with this?
Many weeks with this error... :(

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Mon Feb 09, 2009 3:08 pm
by Armando
Julio:

I use the traditional code (I do not use PPO) and I have no problems, here is a sample.

This is a field and it's propierties

Code: Select all

"PRO_CAN BIT NOT NULL COMMENT 'Cancelado ?'," +;
Then I move all the fields from the record set to variables

Code: Select all

oPro:CAN := oRsPro:Fields("PRO_CAN"):Value
And if I show the oPro:CAN variable I get the .T. or .F. value

Code: Select all

MsgInfo(oPro:CAN)
Regards

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Mon Feb 09, 2009 5:06 pm
by JC
This value field oRsPro:Fields("PRO_CAN"):Value is from the MySQL boolean type?

Into MySQL, the boolean type is tinyint (a numeric value, it can be 0 or 1 ) and when it's access via xHarbour... it's returns a numeric type, not a logical type.

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Mon Feb 09, 2009 6:14 pm
by Armando
Julio:

No, is BIT type, this is the definition

"PRO_CAN BIT NOT NULL COMMENT 'Cancelado ?'," +;

Regards

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Mon Feb 09, 2009 6:24 pm
by JC
In MySQL definition:

Code: Select all

CREATE TABLE test(
   active_register tinyint(1) NOT NULL default 0
);
If you put in this format, the MySQL convert to tinyint again :(

Code: Select all

CREATE TABLE test(
   active_register boolean NOT NULL default 0
);
When we get this value from ADO, it's is numeric!!

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Mon Feb 09, 2009 6:50 pm
by Armando
Julio:

Please try this way

Code: Select all

CREATE TABLE test(
   active_register bit NOT NULL default 0  //  .F.
);
Regards

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Mon Feb 09, 2009 7:30 pm
by JC
Armando wrote:Julio:

Please try this way

Code: Select all

CREATE TABLE test(
   active_register bit NOT NULL default 0  //  .F.
);
Regards
Dear Armando,

This is really very beautiful!
Now it's work perfectly!!

The field must be BIT and no boolean(tinyint)

Thank you for your attention with my problem! ;)

Re: Erroneous conversion type ADO->boolean to xBrowse->logical

Posted: Mon Feb 09, 2009 7:50 pm
by JC
Armando,

I have another doubt!

With fields type timestamp, the xHarbour returns DATE type field...

Code: Select all

CREATE TABLE test(
    date_recognize timestamp not null default current_timestamp
);
I resolve this using like this:

Code: Select all

SELECT date_recognize FROM test;
R=2009-12-24

SELECT CAST( date_recognize AS CHARACTER ) as date_recognize FROM test;
R='2009-12-24 12:12:41'
Exists another way to do?