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

User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post 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!
Last edited by JC on Wed Feb 04, 2009 5:59 pm, edited 2 times in total.
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post 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
Last edited by JC on Wed Feb 04, 2009 5:58 pm, edited 1 time in total.
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post by JC »

Sorry,

Still have error :(
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post by JC »

Please, someone knows?
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post 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!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post by JC »

The self-contained sample with source:

http://rapidshare.com/files/194811022/ADO.zip.html
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post by JC »

Dear friends,

Please, somebody can help me with this?
Many weeks with this error... :(
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

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

Post 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
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post 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.
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

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

Post by Armando »

Julio:

No, is BIT type, this is the definition

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

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post 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!!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

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

Post by Armando »

Julio:

Please try this way

Code: Select all

CREATE TABLE test(
   active_register bit NOT NULL default 0  //  .F.
);
Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post 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! ;)
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

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

Post 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?
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Post Reply