Problema con Listbox y MariaDB

Problema con Listbox y MariaDB

Postby JoseAlvarez » Wed Dec 09, 2020 1: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: Select all  Expand view
cTabla    := _cPrefijo+"_articulos"
cQuery    := "Select * from "+cTabla +" ORDER BY descripcion"
oArticulos:= _oSqlConex:Query( cQuery )    
 

luego mando a hacer esto:

Code: Select all  Expand view
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

Image


ahora bien, si hago esto:

Code: Select all  Expand view

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.

Image

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.
Last edited by JoseAlvarez on Thu Dec 10, 2020 11:43 am, edited 1 time in total.
"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.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: Problema con Listbox y MariaDB

Postby nageswaragunupudi » Wed Dec 09, 2020 2:28 am

Try
Code: Select all  Expand view
oListbox:SetObj( oArticulos )
Regards

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

Re: Problema con Listbox y MariaDB

Postby JoseAlvarez » Wed Dec 09, 2020 2:46 am

Hello Mr. Rao.

Thanks for your attention and help.

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

Image
"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.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: Problema con Listbox y MariaDB

Postby nageswaragunupudi » Wed Dec 09, 2020 3: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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problema con Listbox y MariaDB

Postby JoseAlvarez » Wed Dec 09, 2020 4: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.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: Problema con Listbox y MariaDB

Postby nageswaragunupudi » Wed Dec 09, 2020 6:16 am

This method was not available in your version.

Please keep this function in one of your programs:
Code: Select all  Expand view

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: Select all  Expand view

LbxSetDolphin( oListBox, oAtriculos )
 
Regards

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

Re: Problema con Listbox y MariaDB

Postby JoseAlvarez » 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.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: Problema con Listbox y MariaDB

Postby JoseAlvarez » 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: Select all  Expand view
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 )


Image

we can see all good.

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

Code: Select all  Expand view
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: Select all  Expand view
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.

Image

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

Image

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.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests