FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Problema con Listbox y MariaDB
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Problema con Listbox y MariaDB
Posted: Wed Dec 09, 2020 01:41 AM
Hola a todos.

Saludos.

tengo la siguiente situaci贸n:

una tabla con dos registros de 36 campos (mariaDB)

y hago la siguiente consulta:

Code (fw): Select all Collapse
cTabla 聽 聽:= _cPrefijo+"_articulos"
cQuery 聽 聽:= "Select * from "+cTabla +" ORDER BY descripcion"
oArticulos:= _oSqlConex:Query( cQuery )

luego mando a hacer esto:

Code (fw): Select all Collapse
Redefine ListBox oListbox fields oArticulos:codigo_fabrica , oArticulos:descripcion ,oArticulos:codigo_interno 聽;
聽 聽 聽 聽 聽 聽 聽Id 10 of oDlg Headers 'C贸digo F谩brica','Descripci贸n','Modelo' FieldSizes 聽170 , 410 , 100

resulta que muestra en el listbox un solo registro y repetido 39 veces




ahora bien, si hago esto:

Code (fw): Select all Collapse
cTabla 聽 聽:= _cPrefijo+"_articulos"
cQuery 聽 聽:= "Select * from "+cTabla +" ORDER BY descripcion"
oArticulos:= _oSqlConex:Query( cQuery ) 聽

aArreglo :=oArticulos:FillArray() 聽 //hago una copia del resultado de la consulta

Redefine ListBox oListbox fields aArreglo[oListbox:nAt,1] , aArreglo[oListbox:nAt,2] , aArreglo[oListbox:nAt,3] 聽;
聽 聽 聽 聽 聽 聽 聽Id 10 of oDlg Headers 'C贸digo F谩brica','Descripci贸n','Modelo' FieldSizes 聽170 , 410 , 100


Funciona perfecto y muestra los 2 registros con su informacion correcta.



En el listbox tengo colocado : oListbox:SetArray( oArticulos ) o oListbox:SetArray( aArreglo ) segun el caso

Pregunto: 驴Por que falla usando directamente el resultado de la consulta (oArticulos) pero si trabajo sobre una copia del mismo lo hace bien?
Si consulto la longuitud de oArticulos me dice 39, lo que no es cierto, si consulto la longuitud de la copia es 2, como es correcto.

Como podr谩n ver, es imposible trabajar sobre una copia donde tengo que estar adivinando que elemento voy a mostrar (aArreglo[x,y])
en lugar de llamarlo por su nombre (oArticulo:codigo_fabrica)

Se agradece, como siempre, cualquier ayuda u orientacion pero sobre todo una explicacion de que esta sucediendo.
No soy para nada un experto en mysql/MariaDB. Estoy comenzando apenas.

Un abrazo.
"Los errores en programaci贸n, siempre est谩n entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Problema con Listbox y MariaDB
Posted: Wed Dec 09, 2020 02:28 AM
Try
Code (fw): Select all Collapse
oListbox:SetObj( oArticulos )
Regards



G. N. Rao.

Hyderabad, India
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: Problema con Listbox y MariaDB
Posted: Wed Dec 09, 2020 02:46 AM
Hello Mr. Rao.

Thanks for your attention and help.

I already tried with oListBox: SetObj (oArticles) and got this error:

"Los errores en programaci贸n, siempre est谩n entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Problema con Listbox y MariaDB
Posted: Wed Dec 09, 2020 03:51 AM

Possibly you are using a very old version of FWH.
May I know the version of FWH you are using?

Regards



G. N. Rao.

Hyderabad, India
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: Problema con Listbox y MariaDB
Posted: Wed Dec 09, 2020 04:33 AM

Fw 17.01+ xHarbour + PellesC

"Los errores en programaci贸n, siempre est谩n entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Problema con Listbox y MariaDB
Posted: Wed Dec 09, 2020 06:16 AM
This method was not available in your version.

Please keep this function in one of your programs:
Code (fw): Select all Collapse
function LbxSetDolphin( oLbx, oQry )

   WITH OBJECT oLbx
      :bGoTop    = { || oQry:GoTop() }
      :bGoBottom = { || oQry:GoBottom() }
      :bSkip     = { |nSkip| oQry:Skip( nSkip ) }
      :bLogicLen = { || oQry:RecCount() }
      :cAlias    = "Array"                // Just put something
   END
   
return nil


After creating any listbox (wbrowse) please call this function like this:
Code (fw): Select all Collapse
LbxSetDolphin( oListBox, oAtriculos )
Regards



G. N. Rao.

Hyderabad, India
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: Problema con Listbox y MariaDB
Posted: Wed Dec 09, 2020 11:58 AM

Perfect Mr rao !
it works correctly !

Thank you very much for your kind help.

May I ask why that happens? I don't see a logical explanation if the difference in both cases is that one array is original and the other a perfect copy?

"Los errores en programaci贸n, siempre est谩n entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: Problema con Listbox y MariaDB
Posted: Wed Dec 09, 2020 11:44 PM
Hello Mr. Rao.
I have a new problem with the LISTBOX and the query mariaDB.

In my table there are 2 records. I go to the corresponding function and assemble the query and the listbox like this:

Code (fw): Select all Collapse
cTabla 聽聽:= _cPrefijo+"_usuarios"
cQuery 聽 := "Select * from "+cTabla+" ORDER BY nombre"
oUsuarios:= _oSqlConex:Query( cQuery )
..
..
..
Redefine listbox oLbx fields oUsuarios:nombre 聽 聽聽 聽聽 ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oUsuarios:nick_usuario 聽聽,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oUsuarios:telefono 聽 聽聽 聽,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oUsuarios:status_usuario ,;
聽 聽 聽 聽 聽 Id 10 of oDlg_Usuarios Headers 'Usuario' 聽,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽'Nick' 聽 聽 ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽'Tel茅fono' ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽'Status' 聽聽,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽FieldSizes 聽290 , 120 , 165 , 100
oLbx:SetArray( oUsuarios )
LbxSetDolphin( oLbx, oUsuarios )




we can see all good.

When calling the function to enter a new record and enter the data, I save with this:

Code (fw): Select all Collapse
cQuery :="INSERT IGNORE INTO "+ cTabla 聽+ " SET "
cQuery +="nombre 聽聽 聽 聽 :='" 聽+ Val2escape (cNombreUsuario ) + "',"
cQuery +="telefono 聽聽 聽聽:='" 聽+ Val2escape (cTelefono聽) + "',"
cQuery +="email 聽 聽 聽聽 聽:='" 聽+ Val2escape ( cMail ) 聽 聽+ "',"
cQuery +="nick_usuario聽 :='" 聽+ Val2escape (cNick ) 聽 聽聽+ "',"
cQuery +="clave_usuario :='" 聽+ Val2escape (cClave) 聽 聽聽+ "',"
cQuery +="notas 聽 聽 聽 聽 :='" 聽+ Val2escape (cNotas ) 聽 聽+ "';"

_oSqlConex:Execute( cQuery 聽)


then I do the query again

Code (fw): Select all Collapse
cQuery 聽 聽:= "Select * from "+cTabla+" ORDER BY nombre" 聽 
oUsuarios := _oSqlConex:Query( cQuery ) 聽

oLbx:SetArray(oUsuarios)


when returning to the initial screen, the new inserted record is NOT SHOWN.



But if I go back to the menu and come back, I see everything correct.



In other words, the listbox does not take the update of the new query.

what could be happening? How do I update the listbox with the new content of the query?

Thanks in advance.
"Los errores en programaci贸n, siempre est谩n entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.

Continue the discussion