Page 1 of 4

Browse of my ADO Class

Posted: Thu Sep 19, 2024 5:58 pm
by JoséQuintas

Code: Select all | Expand

   LOCAL cnSQL := ADOLocal()

   cnSQL:Execute( "SELECT * FROM " + workarea )
       @ nRow, nCol XBROWSE xControl ;
            SIZE nWidth, nHeight PIXEL ;
            OBJECT cnSQL ;
            OF xParent ;
            ON DBLCLICK gui_BrowseDblClick( xDlg, xControl, workarea, cField, @xValue )
      FOR EACH aItem IN oTbrowse
         ADD oCol TO xControl ;
            DATA { || cnSQL:Value( aItem[2] ) } ;
            HEADER aItem[1] ;
            PICTURE aItem[3]
      NEXT
      xControl:bLogicLen := { || cnSQL:RecordCount() }
      xControl:bGoTop    := { || cnSQL:MoveFirst() }
      xControl:bGoBottom := { || cnSQL:MoveLast() }
      xControl:bSkip     := { | nSkip, nOld | ADOSkipper( cnSQL, nSkip, nOld ) }
   xControl:nMoveType := 0
   xControl:CreateFromCode()
 
On browse show extra columns, and only one row.
What is wrong ?

Note:
My recordset have 6 columns, I see 9 on browse, and only one row.
same using DATASOURCE or OBJECT

Re: Browse of my ADO Class

Posted: Thu Sep 19, 2024 9:17 pm
by Antonio Linares
Dear Jose,

Mr. Rao is checking it and he will answer you asap,

thank you

Re: Browse of my ADO Class

Posted: Sat Sep 21, 2024 2:22 pm
by JoséQuintas
New test using a dummy array, nArrayAt and bOnSkip only

Code: Select all | Expand

   LOCAL cnSQL := ADOLocal(), aDummy, aCol


   cnSQL:Execute( "SELECT * FROM " + workarea + " ORDER BY " + oTbrowse[ 1, 1 ] )
   IF cnSQL:RecordCount() == 0
      aDummy := {}
   ELSE
      aDummy := Array( cnSQL:RecordCount(), Len( oTBrowse ) )
   ENDIF

         @ nRow, nCol XBROWSE xControl ;
            SIZE nWidth, nHeight PIXEL ;
            ARRAY aDummy ;
            OF xParent

// to check nArrayAt
      ADD oCol TO xControl ;
         DATA { || xControl:nArrayAt } ;
         HEADER "nAT" ;
         PICTURE "999999"
// normal fields
      FOR EACH aItem IN oTbrowse
         ADD oCol TO xControl ;
            DATA { || cnSQL:Value( aItem[2] ) } ;
            HEADER aItem[1] ;
            // PICTURE aItem[3]
      NEXT

// position recordset
      xControl:bOnSkip := { | x | (x), cnSQL:Move( xControl:nArrayAt - 1, 1 ) }

      xControl:SetArray( aDummy )
 
Image

Re: Browse of my ADO Class

Posted: Wed Sep 25, 2024 1:18 am
by JoséQuintas
I was wrong.
My solution with array is not valid for all.
Need cnSQL inside browse class, and codeblocks working to it.

Re: Browse of my ADO Class

Posted: Wed Sep 25, 2024 3:59 pm
by nageswaragunupudi

Code: Select all | Expand

LOCAL cnSQL := ADOLocal()
I understand cnSQL is an ADO Connection Object.
We can not browse a connection object like cnSQL.
We need to create a RecordSet object and browse the recordset object.

Code: Select all | Expand

cnSQL:Value( aItem[2] )
This is an invalid expression and results in runtime error.
Correct expression is

Code: Select all | Expand

oRecordSet:Fields( <name/number> ):Value
We advise studying ADO more. https://www.w3schools.com/asp/ado_intro.asp

Code: Select all | Expand

xControl:bLogicLen := { || cnSQL:RecordCount() }
Please do not mixup WBrowse syntax and XBrowse syntax. There is no data bLogicLen in XBrowse.

We will provide you a working sample showing the best way to
a) create an ADO connection object
b) create a RecordSet object from the connection object and
c) How to create XBrowse to browse the RecordSet. Here we provide 3 different methods to create xbrowse.

In this example, we are connecting to MS-SQL server in the cloud provided by FiveWin for testing by our users. You can copy this sample as it is to fwh\samples folder and build it with buildh or buildx and test it

Code: Select all | Expand

#include "fivewin.ch"

function Main()

   local oCn, nMethod

   FWNumFormat( "E", .t. ) // European number format with thousand sep
   SetGetColorFocus()

   oCn   := msgRun( "Connecting...", "MSSQL Server of FW", ;
         { || FW_OpenAdoConnection( "MSSQL,208.91.198.196,gnraore3_,fwhmsdemo,fwh@2000#", .t. ) } )

   do while ( nMethod := Alert( "Choose xBrowse setup method", { "1", "2", "3", "Exit" } ) ) > 0 ;
      .and. nMethod < 4
      AdoXBrowse( oCn, nMethod )
   enddo

   oCn:Close()

return nil

function AdoXBrowse( oCn, nMethod )

   local oDlg, oBar, oBrw, oFont
   local aCols
   local aHeaders, aPics
   local cTable   := "customer"
   local oRs   // RecordSet object

   oRs   := FW_OpenRecordSet( oCn, "SELECT * FROM " + cTable )

   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 900,600 PIXEL TRUEPIXEL RESIZABLE ;
      FONT oFont TITLE "ADO XBROWSE"

   DEFINE BUTTONBAR oBar OF oDlg SIZE 96,24 2007

if nMethod == 1 //-------------------------

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "ID", "TRIM(FIRST)+', ' + LAST", "City", "SALARY" ;
      HEADERS "RecID", "FullName", , "Amount" ;
      PICTURES nil, nil, "@!" ;
      COLSIZES nil, 200 ;
      CELL LINES NOBORDER AUTOSORT FOOTERS

elseif nMethod == 2  //------------------

   aCols := { ;
      { "ID", "RecID" } ,;
      { "TRIM(FIRST)+', ' + LAST", "FullName", nil, 200 }, ;
      { "City" }, ;
      { "SALARY", "Amount" } }

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS aCols ;
      CELL LINES NOBORDER AUTOSORT FOOTERS

elseif nMethod == 3  //------------------

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS ;
         "ID AS RecID", ;
         "TRIM(FIRST)+', ' + LAST AS FullName WIDTH 200", ;
         "City PICTURE @!", ;
         "SALARY AS Amount" ;
      CELL LINES NOBORDER AUTOSORT FOOTERS

endif

   WITH OBJECT oBrw
      :nEditTypes := EDIT_GET // All fields editable
      :FullName:nEditType := EDIT_NONE
      :Amount:nFooterType := AGGR_SUM
      :MakeTotals()
      //
      :CreateFromCode()
   END

   DEFINE BUTTON OF oBar PROMPT "Edit" CENTER ACTION oBrw:Edit()

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oRs:Close()

return nil
Image

Re: Browse of my ADO Class

Posted: Thu Sep 26, 2024 6:07 pm
by JoséQuintas
Let's simplify, forgot my class.
I want to show numbers from 1 to 10, no array, no recordset, no ADO, no my class
I want to use xbrowse and codeblocks only

Code: Select all | Expand

@ nRow, nCol XBROWSE xControl ;
      SIZE nWidth, nHeight PIXEL ;
       OBJECT Nil ;
        OF xParent
ADD oCol TO xControl ;
   DATA { || xControl:nArrayAt } ;
   HEADER "NUM"

xControl:nArrayAt := 1
xControl:bGoTop := { || xControl:nArrayAt := 1 }
xControl:bGoBottom := { || xControl:nArrayAt := 10 }
??????
 
Same problem on reduced sample.

Is there exists a solution to do this ?
xbrowse and codeblocks only.
It is a standard feature of xbrowse: to define codeblocks.
It is a simple task: show numbers from 1 to 10
And cancel any automatic detection of value used on XBROWSE OBJECT.

Sample on this post use numbers from 1 to 10.
It is a proof about to be possible to define codeblocks.

Can't use multithread... bad but ok
Can't use DBF like on multithread... bad... need change another application to MySQL
My ADOClass ???
It is the remaining one thing that I could use on fivewin.

Re: Browse of my ADO Class

Posted: Fri Sep 27, 2024 11:40 am
by JoséQuintas
I buy fivewin on 2024.08.13 - 6 weeks ago.

Post about multithread was deleted.
Post about BUG on codeblocks on xbrowse have only answer to abandon my class
Abandon multithread
Abandon dbf
Abandon ado class

Support recommend to study ADO, and I use ADO for too many years.
Support recomend myself change xbrowse. (post deleted from here)

On fivewin.com.br I receive wrong answer, and not needed source code is a common task.
Same on others forum.
I buy fivewin to have official support.
On this post, I ask about codeblock does not works.
Rao does not read my post.

Time of Rao to answer is too many time.
My time to abandon my class and change all source code is nothing.
My knowledge of ADO is nothing, he tell about "study ADO".

This is not what I expected from support.
Without support I can't use fivewin.

Don't need to talk about codeblocks.
I really delete all fivewin and all fivewin source code from all.
I will not test nothing more about fivewin.
Worse than product problems is feeling a lack of respect.

I never think to do anything like this, but I want my monkey back.

Re: Browse of my ADO Class

Posted: Fri Sep 27, 2024 11:58 am
by Jimmy
hi,
JoséQuintas wrote:I buy fivewin on 2024.08.13 - 6 weeks ago.
...
what do you expect to LEARN within 6 Weeks :?:

Re: Browse of my ADO Class

Posted: Sun Sep 29, 2024 4:55 pm
by JoséQuintas
Escuse me about my post
I am wrong because I use cumulative results on it, not only what happen on this forum.
May be I use cumulative results with another things.
nageswaragunupudi wrote:Please do not mixup WBrowse syntax and XBrowse syntax. There is no data bLogicLen in XBrowse.
Seems that I do not pay attention to post too.
When a control is showed as the most powerfull control, seems to be the solution for all.
xbrowse is not the unique option, may be wbrowse, may be there are another options, and may be one of them have user codeblocks working.
Jimmy wrote:what do you expect to LEARN within 6 Weeks
May be I am confuse about support.
Once there exists signature to support, I am considering that it will be for limited time.

On 6 weeks:
A full working basic application.
dialog, button, say, get and browse.
Is this too many things for 6 weeks and time limited support?
I think no.
I will continue using harbour, it is not the same as changing programming language.

Like as I sayd on beginning, may be I am using cumulative problems with another things.
Sincerally, I do not remember to see about WBROWSE.

Re: Browse of my ADO Class

Posted: Sun Sep 29, 2024 10:28 pm
by JoséQuintas
If look at wbrowse, codeblocks works !!!!

Code: Select all | Expand

METHOD SetADO( oRs ) CLASS TWBrowse

   ::bGoTop    = { || If( oRs:RecordCount() > 0, oRs:MoveFirst(), nil ) }
   ::bGoBottom = { || If( oRs:RecordCount() > 0, oRs:MoveLast(), nil ) }
   ::bSkip     = { |nSkip,x| If( oRs:RecordCount() < 1, 0, ( x := oRs:AbsolutePosition, ;
                   oRs:AbsolutePosition := Min( Max( 1, x + nSkip ), oRs:RecordCount() ), ;
                   oRs:AbsolutePosition - x ) ) }
   ::bLogicLen = { || oRs:RecordCount() }
   ::cAlias    = "Array"                // Just put something

return nil
 
Reviewing post :
- I ask about codeblock does not works
- I receive a not wanted source code, with no codeblocks
- "You need study ADO"
- "You need study fivewin"


With listbox it works, Rao hasn't ruined the listbox yet
Don't take this the wrong way, it's just a way for you to understand how your response was.
You and I are programmers, so we need to be treated like programmers.

Note: github save my day, deleted repositories remains for 90 days. Do not lost all.

Re: Browse of my ADO Class

Posted: Sun Sep 29, 2024 11:54 pm
by Antonio Linares
Dear Jose,

How may I help you ?

Please let me know what you need. We have not deleted any post from you.

We are here to provide you our best help

thanks

Re: Browse of my ADO Class

Posted: Mon Sep 30, 2024 3:11 am
by JoséQuintas
I want do to a browse.
And want to use the codeblocks to define navigation, and codeblocks to columns

Try listbox/twbrowse and tcbrowse, but until now I can't make any works.
On tcbrowse there exists the add column.
Try to add a property to data too, but no success.

Code: Select all | Expand

      IF Len( aKeyDownList ) == 0
         @ nRow, nCol BROWSE xControl ;
            ; // .. FIELDS ;
            ; // HEADERS "" ;
            SIZE nWidth, nHeight PIXEL ;
            ; // LINES AUTOCOL, AUTOSORT ;
            OF xParent ;
            //ON DBLCLICK gui_BrowseDblClick( xDlg, xControl, workarea, cField, @xValue )
            //LINES CELL
      ELSEIF ( nPos := hb_AScan( aKeyDownList, { | e | e[1] == VK_RETURN } ) ) != 0
         @ nRow, nCol BROWSE xControl ;
            ; // LINES AUTOCOL, AUTOSORT ;
            SIZE nWidth, nHeight PIXEL ;
            OF xParent ;
            //ON DBLCLICK GUI():BrowseKeyDown( VK_RETURN, aKeyDownList, workarea )
            //LINES CELL
      ENDIF
      gui_MsgDebug( ValType( xControl ), xControl:ClassName )
      WITH OBJECT xControl
         :cAlias := "Array"
         :oData := ADOLocal()
         :oData:Execute( "SELECT * FROM " + workarea + " ORDER BY " + oTbrowse[ 1, 1 ] )
         FOR EACH aItem IN oTbrowse
            DO CASE
            CASE .T. // Len( aItem ) < 4
               ADD COLUMN TO xControl ;
                  SHOWBLOCK { || :oData:Value( aItem[2] ) } ;
                  TITLE aItem[1] ;
                  //  PICTURE aItem[3]
               // :AddColumn( oCol := TcColumn():New( aItem[1], { || :oData:Value( aItem[2] ) } ) )
            CASE aItem[ 4 ] == "D"
               // :AddColumn( oCol := TcColumn():New( aItem[1], { || :oData:Date( aItem[2] ) } ) )
            CASE aItem[ 4 ] == "N"
               // :AddColumn( oCol := TcColumn():New( aItem[1], { || :oData:Number( aItem[2] ) } ) )
               //oCol:nAlign := 2
            OTHERWISE
               // :AddColumn( oCol := TcColumn():New( aItem[1], { || :oData:String( aItem[2] ) } ) )
            ENDCASE
         NEXT
         :bGoTop    = { || :oData:MoveFirst() }
         :bGoBottom = { || :oData:MoveLast() }
         :bSkip     = { | nSkip, x | ADOSkipper( :oData:nSkip, x ) }
         :bLogicLen = { || :oData:RecordCount() }
         //xControl:bOnSkip := { | x | (x), xControl:oRs:Move( xControl:nArrayAt - 1, 1 ) }
      ENDWITH
 
add this to confirm if control is created

Code: Select all | Expand

 gui_MsgDebug( ValType( xControl ), xControl:ClassName )
 
Shows "O" and "TCBROWSE"

Error BASE/1004 No exported method: ODATA
Called from ODATA(0)

Code: Select all | Expand

CLASS TWBrowse FROM TControl

   DATA   cAlias, cField, uValue1, uValue2, oData
 

Code: Select all | Expand

CLASS TCBrowse FROM TWBrowse

   CLASSDATA lRegistered AS LOGICAL

   CLASSDATA aProperties AS ARRAY ;
      INIT { "aColumns", "cVarName", "nTop", "nLeft", "nWidth", "nHeight" }

   DATA oData, aColumns, aArray AS ARRAY
 
Ok, once one inherit another, do not need to create oData again, but trying solve error.

Why need to save oData on browse ?
Because I will change later.

Variables are all ok, I can confirm using another library.
And before twbrowse and tcbrowse, I was trying with txbrowse, with same variables.

And yes, I add to recompile wbrowse.prg and tcbrowse.prg and add -ldflags=-Wl,--allow-multiple-definition -s -static
With this flag mingw can duplicate functions on link, on same way as blinker.
Functions on source code have precedence from library functions - I already made this with other fivewin classes on another tests and ok.

Re: Browse of my ADO Class

Posted: Mon Sep 30, 2024 3:32 am
by JoséQuintas
Using external variable:
Seems that tcbrowse have same internal problem as XBROWSE, use only pre-defined data

Code: Select all | Expand

SYSTEM ERROR  
Error DBCMD/2001  Workarea not in use: ORDSETFOCUS  
Called from ORDSETFOCUS(0)  
Called from TCBROWSE:RESETBARPOS(1545)  
Called from TCBROWSE:DEFAULT(672)  
Called from (b)TWBROWSE(187)  
Called from TCBROWSE:INITIATE(0)  
 
with TWBROWSE / LISTBOX, I do not found how to add coluns, do not know if it will works or not with codeblocks.

Trying to make any browse to works for a long time.

At momment unique work solution is on this post, XBROWSE using an array, bOnSkip, but need reload array all time, because other codeblocks fail, only bOnSkip can be used.

About codeblocks:

codeblocks for navigation

Code: Select all | Expand

         :bGoTop    
         :bGoBottom 
         :bSkip     
         :bLogicLen 
 
and codeblocks on columns

Re: Browse of my ADO Class

Posted: Mon Sep 30, 2024 5:24 am
by cnavarro
Dear Jose
I hope to understand your doubts and concerns in this regard, so please tell me if I am right
Just as we define our movement codeblocks in the console in the browse, you want to be able to do the same with XBrowse, is that correct?
What may seem a little "disturbing" at first, in the fact that you apparently cannot define your codeblocks in XBrowse, must indicate that Mr. Rao must have had some reason for doing so, and I think I am not wrong in indicating that since the sources (dbfs, array, ADO, hash, etc.) available to us in the use of this wonderful tool are so wide, it is normal that by default they have been configured specifically for each type of source, since the way in which these codeblocks work in each of these sources has important differences between one another.
In this example that I attached, you can see that the data does not appear because the codeblocks are not defined, but if you comment the :bSkip := nil, or you put your own, the data does appear, which is logical because for the data to appear xbrowse needs to know how to move around the source you have chosen
It is a very powerful tool, but it takes a little time and a lot of testing to get to know its power and the small details that allow us to do everything you can think of in depth

Code: Select all | Expand

#include "fivewin.ch"
#include "xbrowse.ch"

function main()

local oWnd
local oGrid
local oBtn, oGet1, oGet2

   USE CUSTOMER ALIAS "BASE" NEW

   DEFINE WINDOW oWnd
   oWnd:nHeight := ScreenHeight()
   oWnd:nWidth  := ScreenWidth()


   ACTIVATE WINDOW oWnd MAXIMIZED ON INIT Controles( oWnd )

Return nil


Function Controles( oWnd )

   local oGrid

   @ 10, 151 XBROWSE oGrid ;
      SIZE -1, -1 PIXEL ;
      OF oWnd ;
      DATASOURCE "BASE" ;
      AUTOSORT ;
      AUTOCOLS ;
      CELL LINES NOBORDER

    WITH OBJECT oGrid


       :CreateFromCode()

        // User defined codeblocks
       :bGoTop     := nil
       :bGoBottom  := nil
       :bSkip      := nil           // Comment this line or define your own codeblock
       :bBof       := nil
       :bEof       := nil
       //:bKeyNo     := nil
       //:bKeyCount  := nil
       //:bBookMark  := nil

    END

Return nil

 
I also thought I read something related to being able to add columns, I assure you that you can do it both in their initial definition and dynamically at any time: add, delete, hide, etc.
You have many examples in the forum about this and I recommend that you take a look at the include folder in xbrowse.ch where the command to use appears, although I think I remember that xbrowse has a method for it.
Keep in mind that in the GUI environment it is not always developed thinking about code compatibility with the code that was used purely in the console.

What problem do you find with using multithread?

If you have any questions or concerns that I may be able to help you with, I remain at your disposal

-------------------------------- SPANISH ---------------------------------------------

Sorry for my poor English

Estimado Jose
Espero entender tus dudas e inquietudes al respecto, por lo que te ruego me indiques si estoy en lo cierto
Al igual que en consola en el browse definimos nuestros codeblocks de movimiento, deseas poder hacer lo mismo con el XBrowse, es así?
Lo que en principio puede parecerte un poco "inquietante" en el hecho de que aparentemente no consigas definir tus codeblocks en el XBrowse, debe de indicarte que algún motivo habrá tenido el Sr. Rao para hacerlo así, y creo que no me equivoco al indicar que al ser tan amplios los sources ( dbfs, array, ADO, hash, etc ) de que disponemos en la utilizacion de esta maravillosa herramienta, es normal que por defecto se hayan configurados de forma específica para cada tipo de source, ya que la forma en la que funcionan en cada uno de esos sources esos codeblocks, tienen diferencias importantes entre unos y otros.
En este ejemplo que te adjunto, podrás comprobar que no aparecen los datos ya que no están definidos los codeblocks, pero el comentas el :bSkip := nil, o pones el tuyo propio, si aparecen los datos, lógico porque para que vayan apareciendo los datos xbrowse necesita saber como moverse por el source que hayas elegido
Es una herramienta muy poderosa, pero se necesita un poco de tiempo y muchas pruebas para ir conociendo en profundidad su potencia y los pequeños detalles que nos permiten hacer todo lo que se te pueda ocurrir

También me ha parecido leer algo relacionado con poder añadir columnas, te aseguro que se puede tanto en su definición inicial como dinámicamente en cualquier momento: añadir, borrar, ocultar, etc.
Tienes muchos ejemplo en el foro al respecto y te recomiendo que le eches un vistazo en la carpeta include a xbrowse.ch en el que aparece el comando a utilizar, aunque creo recordar que el xbrowse tiene un method para ello.
Piensa que en el entorno GUI no siempre se desarrolla pensando en la compatibilidad de código con el código que se utilizaba puramente en consola.

Qué problema encuentras con el uso de multithread?

Cualquier duda en la que pueda ayudarte, quedo a tu disposición

Re: Browse of my ADO Class

Posted: Mon Sep 30, 2024 9:03 am
by nageswaragunupudi
JoséQuintas wrote:I buy fivewin on 2024.08.13 - 6 weeks ago.

Post about multithread was deleted.
Post about BUG on codeblocks on xbrowse have only answer to abandon my class
Abandon multithread
Abandon dbf
Abandon ado class

Support recommend to study ADO, and I use ADO for too many years.
Support recomend myself change xbrowse. (post deleted from here)

On fivewin.com.br I receive wrong answer, and not needed source code is a common task.
Same on others forum.
I buy fivewin to have official support.
On this post, I ask about codeblock does not works.
Rao does not read my post.

Time of Rao to answer is too many time.
My time to abandon my class and change all source code is nothing.
My knowledge of ADO is nothing, he tell about "study ADO".

This is not what I expected from support.
Without support I can't use fivewin.

Don't need to talk about codeblocks.
I really delete all fivewin and all fivewin source code from all.
I will not test nothing more about fivewin.
Worse than product problems is feeling a lack of respect.

I never think to do anything like this, but I want my monkey back.
Kindly accept my sincere apologies.
We are all at the service of our users at all times.