Buenas, no logro insertar registros en una BD ACCESS, utilizo el siguiente código copiado del ejemplo TESTXBR3.PRG,al cual le paso lo mismo.
el XBROWSE lo refleja correctamente, ALTAS, BAJAS, MODIFICACIONES, pero al salir y volver a entrar veo que en la BD no queda reflejado nada y tampoco da error.
Saben que ocurre?. Alguna solución?
oRs := FW_OpenRecordSet( oDg, "Marcas", adLockBatchOptimistic )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE WINDOW oDlg MDICHILD OF WndMain() TITLE cTitulo
@ 0,0 XBROWSE oBrw ;
COLUMNS "cCodMar", "cDesMar" ;
OF oDlg ;
RECORDSET oRs ;
AUTOSORT FOOTERS FASTEDIT LINES CELL
AEval( oBrw:aCols, { |o| o:cToolTip := { 'Column :' + CRLF + o:cHeader, 'ToolTip' }, ;
o:nEditType := EDIT_GET } )
WITH OBJECT oBrw
:bPopUp := { |o| ColMenu( o ) }
:MakeTotals()
:CreateFromCode()
END
oWnd:oClient := oBrw
oWnd:bPostEnd := { || oRs:Close() }
BtnBar( oBrw )
Insertar/Modificar registros en ACCESS
Re: Insertar/Modificar registros en ACCESS
+1
Saludos
Saludos
Re: Insertar/Modificar registros en ACCESS
Con HDO directamente o con HDORDD se puede hacer sin problemas...
______________________________________________________________________________
Sevilla - Andalucía
Sevilla - Andalucía
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Insertar/Modificar registros en ACCESS
Isn't HDO based on ADO?xmanuel wrote:Con HDO directamente o con HDORDD se puede hacer sin problemas...
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Insertar/Modificar registros en ACCESS
Please see your code
If you change it as
everything works correctly as expected.
First please try it before getting into the next discussion.
If you open the recordset with adLockBatchOtpimistic mode, all changes (modifications, deletions and appends) are written only to the Recordset in our PC's MEMORY ONLY but NOT written to the physical database.
To finally save all the changes at once to the physical database, you need to call oRs:UpdateBatch() or abandon all changes by calling oRs:CancelBatch() or simply closing the recordset by calling oRs:Close()
In the above example, you are closing the RecordSet without saving the changes by calling oRs:UpdateBatch. So all the changes are lost.
In the above example, if you still want to open with adLockBatchOptimistic mode, change this code:
as
With this change, your modifications, deletes and appends are not written to the physical database as and when the user makes them, but all these changes are dumped to the physical database when the MdiChild window is closed.
So
1) If you want to save the changes to the physical database immediately as and when the user edits the browse, you open recordset with default lockmode provided by FWH or specifying adLockOptimistic mode.
OR
2) If you do not want to make the changes during edit but after closing the window, then open the reocordset with "adLockBatchOptimistic" locking and towards the end save all the changes by calling oRs:UpdateBatch() before calling oRs:Close()
Note:
We advise you use the default mode (i.e., adLockOptimistic) till you master ADO and learn to handle resolution of conflicts while calling oRs:UpdateBatch(). This is after you gain mastery over ADO.
Code: Select all
oRs := FW_OpenRecordSet( oDg, "Marcas", adLockBatchOptimistic )
Code: Select all
oRs := FW_OpenRecordSet( oDg, "Marcas" )
//OR
oRs := FW_OpenRecordSet( oDg, "Marcas", adLockOptimistic )
// default lockmode is adLockOptimistic
First please try it before getting into the next discussion.
If you open the recordset with adLockBatchOtpimistic mode, all changes (modifications, deletions and appends) are written only to the Recordset in our PC's MEMORY ONLY but NOT written to the physical database.
To finally save all the changes at once to the physical database, you need to call oRs:UpdateBatch() or abandon all changes by calling oRs:CancelBatch() or simply closing the recordset by calling oRs:Close()
In the above example, you are closing the RecordSet without saving the changes by calling oRs:UpdateBatch. So all the changes are lost.
In the above example, if you still want to open with adLockBatchOptimistic mode, change this code:
Code: Select all
oWnd:bPostEnd := { || oRs:Close() }
Code: Select all
oWnd:bPostEnd := { || oRs:UpdateBatch(), oRs:Close() }
So
1) If you want to save the changes to the physical database immediately as and when the user edits the browse, you open recordset with default lockmode provided by FWH or specifying adLockOptimistic mode.
OR
2) If you do not want to make the changes during edit but after closing the window, then open the reocordset with "adLockBatchOptimistic" locking and towards the end save all the changes by calling oRs:UpdateBatch() before calling oRs:Close()
Note:
We advise you use the default mode (i.e., adLockOptimistic) till you master ADO and learn to handle resolution of conflicts while calling oRs:UpdateBatch(). This is after you gain mastery over ADO.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 78
- Joined: Wed May 31, 2006 8:49 am
Re: Insertar/Modificar registros en ACCESS
Perfectamente explicado y entendido
Muchas Gracias.
Muchas Gracias.