xBrowse + MySql and column sequence ...

xBrowse + MySql and column sequence ...

Postby Rimantas » Thu Feb 28, 2013 6:41 pm

Hi,

I'm trying to rewrite one appl. from dbfs to mysql db . The first problem is to restore clients directed column sequence . That is at first was "order_id,item_id", but client moved columns "item_id,order_id" . Working with dbfs I used Hernans wbrowse class adopted for mine needs . Then I could create array for codeblocks in needfuls sequence and oBrw:bLine := { || brw_line( aFlds) } works fine ...
OK , let say that I retored needful sequence columns for client . From MySql server query I can to do :

aDgr := grd_set( cTbl, aGrd, cLg ) // restore settings of columns - sequence , width , visible ... etc.
cFld := aDgr[ 1, 1 ];
cSql := "select " + cFld + " from " + cTbl + " where " + cTbl + ".db = '" + cDb_id + "'"
oQry := oServ:Query( cSql )

Now begin to describe xBrowse :

aFld := aDgr[ 2 ] // fields in needfuls sequence ...
oBrw := TXBrowse():New( oWnd )
oBrw:SetMySQL( @oQry )
for u := 1 to len( aFld )
oCol := oBrw:AddCol()
oCol:bStrData := { ||oQry:aFld[ u ] }
...
next

Here I stoped . I didn't tried this yet , because I'm in doubt . Question : will this oCol:bStrData := { ||oQry:aFld[ u ] } work ? If not , how can this be done ?

Thanks in advance ! Rimantas
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: xBrowse + MySql and column sequence ...

Postby nageswaragunupudi » Fri Mar 01, 2013 4:36 am

Please try

Code: Select all  Expand view

@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE oQry ;
    COLUMNS "fldName1", "fldName2", ..., "fldNameN"
 


Note: Even while coding the old style, please do not use bStrData. Instead use bEditValue.
Regards

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

Re: xBrowse + MySql and column sequence ...

Postby Rimantas » Fri Mar 01, 2013 8:59 am

nageswaragunupudi wrote:Please try

Code: Select all  Expand view

@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE oQry ;
    COLUMNS "fldName1", "fldName2", ..., "fldNameN"
 

Note: Even while coding the old style, please do not use bStrData. Instead use bEditValue.


Thanks for the reply ! Thanks for advice to use bEitValue . OK , let say that at first described XBROWSE with COLUMNS manier . User changed cols sequence , I saved new sequence . Now closing and opeing window I must to restore saved column sequence . It will be suffice to direct new column sequence ? As I can understand I must to use vars instead fieldnames . It will looks like that :

"@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE oQry COLUMNS cMineColumnSquence"

Not worked with FWH about 1 year . Have FWH 11.12 version . Do not have experience with xBrowse . So excuse for stupid questions ... I'm coming back ! :-)
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: xBrowse + MySql and column sequence ...

Postby nageswaragunupudi » Fri Mar 01, 2013 3:20 pm

To save the last used state of xbrowse, we can save the state with cSaveState := oBrw:SaveState() and in the next session restore the same the state with oBrw:RestoreState( cSavedState )

We need not always specify the column names as literals.

We can use an array like this:
aColNames := { "FIRSTNAME", "LASTNAME", "CITY". ...... }
and then
@ 10,10 XBROWSE oBrw ............ COLUMNS aColNames ............etc
Regards

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

Re: xBrowse + MySql and column sequence ... Solved

Postby Rimantas » Fri Mar 01, 2013 5:00 pm

nageswaragunupudi wrote:To save the last used state of xbrowse, we can save the state with cSaveState := oBrw:SaveState() and in the next session restore the same the state with oBrw:RestoreState( cSavedState )
We need not always specify the column names as literals.
We can use an array like this:
aColNames := { "FIRSTNAME", "LASTNAME", "CITY". ...... }
and then
@ 10,10 XBROWSE oBrw ............ COLUMNS aColNames ............etc


Thanks for your help !
At first I created xbrowse without any descriptions of cols . Mine code :

Code: Select all  Expand view

local oWnd, oBrw, oQry
local aDgr, aCol
local cFld
local cSql
local cTbl := "uzsakym"
local aGrd := { ;
{ "uzsak"        , "Order.ID"         }, ;
{ "telkinys"     , "Pool"             }, ;
{ "preke"        , "Item ID"          }, ;
{ "uzs_kiekis"   , "Qty."             }, ;
{ "svarbus"      , "Import."          }, ;
{ "specai"       , "Spec."            }, ;
{ "mazi"         , "Smalls"           }, ;
{ "uzs_spalv"    , "Ord.colors"       }, ;
{ "uzs_data"     , "Ord.date"         }, ;
{ "uzs_sav"      , "Ord.week"         }, ;
{ "graz_data"    , "Ret.date"         }, ;
{ "graz_sav"     , "Ret.week"         }, ;
{ "fakt_data"    , "Fact.date"        }, ;
{ "fakt_sav"     , "Fact.week"        }, ;
{ "pastabos_ord" , "Ord.note"         }, ;
{ "zymos"        , "Notes"            }, ;
{ "kerpa"        , "Cutting"          }, ;
{ "sukirp_lap"   , "Cut.page"         }, ;
{ "etiketes"     , "Labels"           }, ;
{ "gav_data"     , "Recv.date"        }, ;
{ "subrang"      , "Subcontr."        }, ;
{ "aud_nuras"    , "Mater.off"        }, ;
{ "frn_nuras"    , "Furnit.off"       }, ;
{ "invc_nuras"   , "Invoice off"      }, ;
{ "nav_nuras"    , "NAV off"          }, ;
{ "pasel_prad"   , "Mak.begin"        }, ;
{ "pokav_prad"   , "Pack.begin"       }, ;
{ "prilyg_mod"   , "Equat.model"      }, ;
{ "prilyg_kiekis", "Eq.qty"           }, ;
{ "pastabos_buh" , "Account notes"    }, ;
{ "buh_specas"   , "Buh.spec"         }, ;
{ "pastabos_zs"  , "Notes of Zarasai" }, ;
{ "pok_lap_mod"  , "Pack.list model"  } }

aDgr := grd_set( cTbl, aGrd, cLg )
cFld := aDgr[ 1 ]
aCol := aDgr[ 2 ]
cSql := "select " + cFld + " from uzsakym where uzsakym.db = '" + cDb_id + "'"
oQry := oServ:Query( cSql )

MsgInfo( cFld )
MsgInfo( cSql )
MsgInfo( valtoprg( aCol ) )

DEFINE WINDOW oWnd TITLE "Užsakymai" MDICHILD OF wndMain()
   
@ 0, 0 XBROWSE oBrw OF oWnd DATASOURCE oQry COLUMNS aCol
oBrw:SetMySQL( oQry )
oBrw:CreateFromCode()

oWnd:oClient := oBrw

ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus()

return( NIL )
 


But it returns error :

Code: Select all  Expand view

Application
===========
   Path and name: D:\A\Amdi2\engel.exe (32 bits)
   Size: 3,318,757 bytes
   Compiler version: Harbour 3.1.0dev (Rev. 17140)
   FiveWin  Version: FWH 11.10
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 0 mins 7 secs
   Error occurred at: 2013.03.01, 18:36:05
   Error description: Error BASE/44  Assigned value is wrong class: TXBROWSE:NLEN
   Args:
     [   1] = C  

Stack Calls
===========
   Called from:  => TXBROWSE:_NLEN( 0 )
   Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE( 0 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:KEYCOUNT( 0 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:ADJUST( 0 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:INITIATE( 0 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:CREATEFROMCODE( 0 )
   Called from: uzs.prg => UZSAK( 62 )
   Called from: engel.prg => RUN_PRG( 441 )
   Called from: engel.prg => (b)MENU_RUN( 433 )
   Called from: .\source\classes\VISTAMNU.PRG => TVISTAMENU:LBUTTONUP( 0 )
   Called from: .\source\classes\CONTROL.PRG => TVISTAMENU:HANDLEEVENT( 0 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 0 )
   Called from:  => WINRUN( 0 )
   Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 0 )
   Called from: engel.prg => MAIN( 243 )
 


Added xbrowse.prg from sources to mine project. Now it's directed to error line ( 407 ) . This line :

METHOD KeyCount() INLINE ( ::nLen := Eval( ::bKeyCount ),;
iif(::oVScroll != nil ,;
( ::VSetRange( 1, ::nLen ), ::VUpdatePos() ), ),;
::nLen )

What that mean ? Empty query ?

I also added this :

u := 0
oQry:GoTop()
while !oQry:eof()
MsgInfo( oQry:uzsak + " " + oQry:preke )
oQry:skip()
u ++
if ( u == 5 )
exit
endif
enddo

Query isn't empty . Also tried with only first 3 columns : "uzsak", "telkinys", "preke" . They are varchar types only . The same result ... What that is bad ? Can you help me ?

P.S.: At this moment I noticed that mine version of Fwh is 11.11 , not 11.12 ... :(

With best regards ! Rimantas

ADDED ! This problem solved : Simply in xBrowse was query method ::oMysql:RecCount() , but in TMySql is ::oMysql:LastRec() . Changed , now I can see data of query in xBrowse ... :)
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: xBrowse + MySql and column sequence ...

Postby nageswaragunupudi » Fri Mar 01, 2013 6:35 pm

1. @ r,c XBROWSE .... command itself calls oBrw:SetMySql(oQry). Please remove the specific call to SetMySql in the next line and try.

2. I do not have the version 11.11 with me. In the absence of the actual source code, I may not be able to advise you correctly.
It will be helpful if you can send me the source of xbrowse.prg of 11.11 version to my personal email : nageswaragunupudi@gmail.com. That helps me to help you in future.
Regards

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

Re: xBrowse + MySql and column sequence ...

Postby nageswaragunupudi » Sat Mar 02, 2013 5:26 pm

1. @ r,c XBROWSE .... command itself calls oBrw:SetMySql(oQry). Please remove the specific call to SetMySql in the next line and try.

Have you tried this? May I know the result?

I have received the xbrowse.prg. I shall refer to that whenever necessary.
Regards

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

Re: xBrowse + MySql and column sequence ...

Postby Rimantas » Sat Mar 02, 2013 7:09 pm

nageswaragunupudi wrote:
1. @ r,c XBROWSE .... command itself calls oBrw:SetMySql(oQry). Please remove the specific call to SetMySql in the next line and try.

Have you tried this? May I know the result?

I have received the xbrowse.prg. I shall refer to that whenever necessary.


Yes , I tried this . Working fine ! Thank yoo , Rao ... :)
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 30 guests