Hi,
I have a Xbrowse with a record set .
Is it possible to refresh the record set only for the current line of the xbrowse .
I"d like to make a requery only for the current record .
Thanks .
Hi,
I have a Xbrowse with a record set .
Is it possible to refresh the record set only for the current line of the xbrowse .
I"d like to make a requery only for the current record .
Thanks .
Jack
If you are using the same oRs recordset to edit the record, at the end of your edit routine make sure you issue oRs:Update() .. and to refresh xBrowse, oLbx:ReFresh(). If you create a new oRs recordset to edit the record .. YES, you will need to ReSync ( not requery ) the original xBrowse recordset record with oRs:Resync( 1, 2 ), then oLbx:ReFresh(). Issuing the ReSync() method only updates the current selected record with new values and does not force the entire recordset to be refreshed.
Rick Lipkin
If you create a new recordset to edit the record better is to clone ex oRsNew := oRs:Clone and then you need to do nothing ADO will keep both synchronized (with same data) till you issue again :requery on the original.
Please remember that you will need to close both sets.
I think i will do this :
oLbx:bLDblClick = { | nRow, nCol | (EDFUNC(oRs:Fields("ID"):Value),oRs:resync(1,2),oLbx:refresh())}
function EDFUNC(pid)
local cSql
...edit fields
cSQL := "UPDATE PATREC SET NAME="+"'"+alltrim(wname)+"'" +" WHERE ID="+"'"+alltrim(pid)+"'"
TRY
oCon:Execute(cSql)
CATCH oErr
ShowAdoEr( oCon,csql )
END TRY
*
return .T.
Jack wrote:oRs:resync(1,2)
oRs:resync(1)function EDFUNC(pid)
local cSql
...edit fields
cSQL := "UPDATE PATREC SET NAME="+"'"+alltrim(wname)+"'" +" WHERE ID="+"'"+alltrim(pid)+"'"
TRY
oCon:Execute(cSql)
CATCH oErr
ShowAdoEr( oCon,csql )
END TRY
*
return .T.
Anyway, Resync method never worked for me...
AHF wrote:Enrico in what context?
I just test it and it works .
ID is a unique value .
Thanks for this help .
Jack wrote:I just test it and it works .
//-------
Func _EditUm( oRs,oLbx,cSql )
Local nEId,oRs2
nEid := oRs:Fields("PrimaryKey"):Value
// do your edits with another oRs2
oRs2:CLose()
oRs:CLose() // yes close the orig recordset assoc with oLbx
// do not redefine oRs .. just reuse
// cSql is the original query statement
TRY
oRs:Open( cSQL,oCONNECT ) // oConnect is a defined public connection object
CATCH oErr
MsgInfo( "Error in Opening table" ) // bad news if this happens
RETURN(.F.)
END TRY
oRs:MoveFirst()
oRs:Find( "[PrimaryKey] = "+ltrim(str(nEid)) )
oLbx:ReFresh()
Return(.t.)I think Resync issues some kind of SQL query based on primary key to get back the values from source.
When you dont have the primary key included in your set you will get into problems with resync otherwise in all my tests with several dbs (MySql, PostGre, SQlite, Firebird, Access ) works ok.
In all my tests with adordd didnt get any problems because primary key (recno) its always included in the set.
resync doesnt works also with addnew when the db engine works with Sequences or Generators again because after adding the new row the set doesnt get immediately the primary key value and thus you need to either save the next Sequence or Generated key yourself with addnew or simply requery it after.
In all other situations resync seems to work ok.
I dont have experience in batchupdates.