Page 1 of 1

Open 3 SQL tables

Posted: Tue Feb 16, 2021 7:48 pm
by ctoas
Hello friends.

In a module, I have a mysql table loaded and I need to open two more to save data, but when I try to do an xBrowse with data from the second or third it presents an error.

Code: Select all

    oRsLOTEAMENTO := oServer:ROWSET("SELECT * FROM loteamentos ORDER BY nome")
    oRsSOCIOS     := oServer:ROWSET("SELECT * FROM socio ORDER BY loteamento")
    oRsLOTES      := oServer:ROWSET("SELECT * FROM lotes ORDER BY loteamento")
 

Code: Select all

       @ 0069,0000 XBROWSE oBrwLOTEAMENTOS OF oDlgLOTEAMENTOS SIZE 0520,0230 STYLE FLAT PIXEL NOBORDER DATASOURCE oRsLOTEAMENTO//AUTOSORT   
            
        ADD TO oBrwLOTEAMENTOS DATA oRsLOTEAMENTO:nome   PICTURE "@!" HEADER "Nome"   WIDTH 520
        ADD TO oBrwLOTEAMENTOS DATA oRsLOTEAMENTO:bairro PICTURE "@!" HEADER "Bairro" WIDTH 260               
        ADD TO oBrwLOTEAMENTOS DATA oRsLOTEAMENTO:cidade PICTURE "@!" HEADER "Cidade" WIDTH 260               

        oBrwLOTEAMENTOS:nColDividerStyle := 0          
        oBrwLOTEAMENTOS:nRowDividerStyle := 0           
        oBrwLOTEAMENTOS:nMarqueeStyle    := 5
        oBrwLOTEAMENTOS:lHScroll         := .F.
        oBrwLOTEAMENTOS:lVScroll         := .T.
        oBrwLOTEAMENTOS:lRecordSelector  := .F.
        oBrwLOTEAMENTOS:bKeyChar         := {|nKey|IIF(nKey==VK_RETURN,((OPERACAO_LOTEAMENTOS(2))),)}
        oBrwLOTEAMENTOS:bClrSelFocus        := {||{nRGB(000,000,000),nRGB(150,150,150)}}
        oBrwLOTEAMENTOS:bClrSel            := {||{nRGB(000,000,000),nRGB(150,150,150)}}
        oBrwLOTEAMENTOS:bClrStd             := {||{CLR_BLUE,IIF(oRsLOTEAMENTO:KeyNo() %2==0,CLR_WHITE,nRGB(232,232,232))}}
        oBrwLOTEAMENTOS:nHeaderHeight    := 40 
        oBrwLOTEAMENTOS:bClrHeader       := {||{nRGB(000,000,000),nRGB(150,150,150)}}
        oBrwLOTEAMENTOS:bSeek            := {|c|.F.}
            
        oBrwLOTEAMENTOS:aCols[1]:oHeaderFont := ARIAL16B
        oBrwLOTEAMENTOS:aCols[1]:bLClickHeader := {|r,c,f,o| nil}
        oBrwLOTEAMENTOS:aCols[2]:oHeaderFont := ARIAL16B  
        oBrwLOTEAMENTOS:aCols[2]:bLClickHeader := {|r,c,f,o| nil}
        oBrwLOTEAMENTOS:aCols[3]:oHeaderFont := ARIAL16B  
        oBrwLOTEAMENTOS:aCols[3]:bLClickHeader := {|r,c,f,o| nil}
                
        oBrwLOTEAMENTOS:CreateFromCode()
 

Code: Select all

       @ 0069,0000 XBROWSE oBrwSOCIOS OF oFldLOTEMENTOS:aDialogs[2] SIZE 0120,0230 STYLE FLAT PIXEL NOBORDER DATASOURCE oRsSOCIOS
            
       ADD TO oBrwLOTEAMENTOS DATA oRsSOCIOS:nome        PICTURE "@!"  HEADER "Nome" WIDTH 0520     <------ ERROR !!!!
       ADD TO oBrwLOTEAMENTOS DATA oRsSOCIOS:porcentagem PICTURE "999" HEADER "%"    WIDTH 0018                  

        oBrwSOCIOS:nColDividerStyle := 0          
        oBrwSOCIOS:nRowDividerStyle := 0           
        oBrwSOCIOS:nMarqueeStyle    := 5
        oBrwSOCIOS:lHScroll         := .F.
        oBrwSOCIOS:lVScroll         := .T.
        oBrwSOCIOS:lRecordSelector  := .F.
        oBrwSOCIOS:bKeyChar         := {|nKey|IIF(nKey==VK_RETURN,((OPERACAO_LOTEAMENTOS(2))),)}
        oBrwSOCIOS:bClrSelFocus      := {||{nRGB(000,000,000),nRGB(150,150,150)}}
        oBrwSOCIOS:bClrSel           := {||{nRGB(000,000,000),nRGB(150,150,150)}}
        oBrwSOCIOS:bClrStd           := {||{CLR_BLUE,IIF(oRsSOCIOS:KeyNo() %2==0,CLR_WHITE,nRGB(232,232,232))}}
        oBrwSOCIOS:nHeaderHeight    := 40 
        oBrwSOCIOS:bClrHeader       := {||{nRGB(000,000,000),nRGB(150,150,150)}}
        oBrwSOCIOS:bSeek            := {|c|.F.}
            
        oBrwSOCIOS:aCols[1]:oHeaderFont := ARIAL16B
        oBrwSOCIOS:aCols[1]:bLClickHeader := {|r,c,f,o| nil}
        oBrwSOCIOS:aCols[2]:oHeaderFont := ARIAL16B  
        oBrwSOCIOS:aCols[2]:bLClickHeader := {|r,c,f,o| nil}
                
        oBrwSOCIOS:CreateFromCode()
 
Error description: Error BASE/1004 Class: 'NIL' has no exported method: NOME
ADD TO oBrwLOTEAMENTOS DATA oRsSOCIOS:nome        PICTURE "@!"  HEADER "Nome" WIDTH 0520

Can someone help?

Thanks

Re: Open 3 SQL tables

Posted: Tue Feb 16, 2021 10:04 pm
by nageswaragunupudi
Error description: Error BASE/1004 Class: 'NIL' has no exported method: NOME
That means this sql statement failed to open rowset.

Code: Select all

oRsSOCIOS     := oServer:ROWSET("SELECT * FROM socio ORDER BY loteamento")
 
Whenever you try to open a rowset, check if the rowset is opened successfully or not.

Code: Select all

oRs := oCn:RowSet( ... )
if oRs == nil
   // failed to open
   // take appropriate action
endif
 

Re: Open 3 SQL tables

Posted: Tue Feb 16, 2021 10:10 pm
by nageswaragunupudi
Important advice for creating xbrowse:

Code: Select all

       @ 0069,0000 XBROWSE oBrwLOTEAMENTOS OF oDlgLOTEAMENTOS SIZE 0520,0230 STYLE FLAT PIXEL NOBORDER DATASOURCE oRsLOTEAMENTO//AUTOSORT   
            
        ADD TO oBrwLOTEAMENTOS DATA oRsLOTEAMENTO:nome   PICTURE "@!" HEADER "Nome"   WIDTH 520
        ADD TO oBrwLOTEAMENTOS DATA oRsLOTEAMENTO:bairro PICTURE "@!" HEADER "Bairro" WIDTH 260              
        ADD TO oBrwLOTEAMENTOS DATA oRsLOTEAMENTO:cidade PICTURE "@!" HEADER "Cidade" WIDTH 260              
 
Please do not create xbrowse and add columns with "ADD TO oBrw" command
Long long time back we created these commands to make it easy for users to migrate from wbrowse and tcbrowse to xbrowse.
These commands do not let you avail the full power of xbrowse.

Please create like this:

Code: Select all

@ 0069,0000 XBROWSE oBrwLOTEAMENTOS OF oDlgLOTEAMENTOS SIZE 0520,0230 STYLE FLAT PIXEL NOBORDER DATASOURCE oRsLOTEAMENTO ;
   COLUMNS "Nome", "Barirro", "Cidade" ;
   ; // HEADERS ... only if headers are different from column names
   PICTURES "@!","@!", "@!"
 

Re: Open 3 SQL tables

Posted: Tue Feb 16, 2021 11:47 pm
by ctoas
Thanks Nages (How should we call you Nages or Rao?)

I found my stupidity ... kkkk

Just let me ask you one more question about xBrowse.
Would you like to remove any visual effect from the header when clicked and also the arrow indicating the sorting, is it possible?
Use

Code: Select all

oBrw:aCols[1]:bLClickHeader := {|r,c,f,o| nil}
this removes the change of order, but not the visual effects

Thanks

Re: Open 3 SQL tables

Posted: Wed Feb 17, 2021 8:27 am
by Enrico Maria Giordano
ctoas wrote:(How should we call you Nages or Rao?)
+1 :-)

EMG

Re: Open 3 SQL tables

Posted: Thu Feb 18, 2021 6:21 am
by nageswaragunupudi
Enrico Maria Giordano wrote:
ctoas wrote:(How should we call you Nages or Rao?)
+1 :-)

EMG
Rao

Re: Open 3 SQL tables

Posted: Thu Feb 18, 2021 6:22 am
by nageswaragunupudi
this removes the change of order, but not the visual effects
Please let me know the FWH version you are using.

Re: Open 3 SQL tables

Posted: Thu Feb 18, 2021 8:51 am
by Enrico Maria Giordano
nageswaragunupudi wrote:
Enrico Maria Giordano wrote:
ctoas wrote:(How should we call you Nages or Rao?)
+1 :-)

EMG
Rao
Ok, Mr. Rao!

EMG

Re: Open 3 SQL tables

Posted: Thu Feb 18, 2021 4:16 pm
by ctoas
Hello Mr. Rao

I'm using version 18.01

Re: Open 3 SQL tables

Posted: Sun Feb 21, 2021 8:31 pm
by nageswaragunupudi
We have not provided any simple way to prevent the painting of the sort bitmaps.

I suggest this work-around:

Code: Select all

oBrw:cSortOrders := ""