Mr. Rao. REQUERY FWH Nativa.

Mr. Rao. REQUERY FWH Nativa.

Postby Ariel » Thu Sep 12, 2019 3:55 pm

buenas,

tengo un select id,nombre,direccion, cuando lo edito en el xbrowse, quiero editar TODOS los campos de la tabla (son 30 por ejemplo), como hago para traer todos los campos ?
intente :

cStr:= ""
aEval( ::oConn:ListColumns("clientes"), {| o | cStr += If( Empty( cStr ), "", "," )+AllTrim( o[1] ) } )

::oCliente:= ::oQuery:Record( cStr ) // Devuelve el registro señalado en el Browse
// ::oQryP:Source = cQuery de Dolphin
if ValType( ::oCliente ) == "O"
//if ::oCliente <> nil
? ::oCliente:Apellido, ::oCliente:Nombre, ::oCliente:direccion
end

pero solo me trae los de la consulta inicial

Gracias.
Ariel
 
Posts: 376
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: Mr. Rao. REQUERY FWH Nativa.

Postby nageswaragunupudi » Thu Sep 12, 2019 4:14 pm

With FWH builtin mysql/mariadb library, use the method
Code: Select all  Expand view  RUN

EditBaseRecord( [cFieldList], [lNew], [bEdit], [oBrw], [lLock] )
 

This method reads all fields from the database and offers for edit. When saved, the rowset in the memory is updated.

Notes:
1) The table must have a primary key.
2) The query should include the primary key.

Sample code:
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oCn
   local oRs, oDlg, oFont, oBrw, oBar, bEdit

   oCn   := FW_DemoDB()

   oRs   := oCn:RowSet( "select id, first, city, salary from customer" )
            // The table SHOULD have a primary key.
            // The query SHOULD include the primary key.


// bEdit := { |oRec| MyEditDialog( oRec ) }
// In your program, you design your own dialog

   XBROWSER oRs

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 700,600 PIXEL TRUEPIXEL FONT oFont

   DEFINE BUTTONBAR oBar SIZE 80,32 2010
   DEFINE BUTTON OF oBar PROMPT "New"  ACTION oRs:EditBaseRecord( nil, .t., bEdit, oBrw )
   DEFINE BUTTON OF oBar PROMPT "Edit" ACTION oRs:EditBaseRecord( nil, .f., bEdit, oBrw )

   @ oBar:nHeight, 20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs AUTOCOLS ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oCn:Close()

return nil
 


You may test this first and then apply to your table
Regards

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


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 70 guests