One more question please. What is the equivalent for rlock()?.
IF RLOCK()
Delete
UNLOCK
ELSE
? "Record update failed"
return .f.
ENDIFI need to lock the record before deleting it.
Thanks.
IF RLOCK()
Delete
UNLOCK
ELSE
? "Record update failed"
return .f.
ENDIFoRsGs := TOleAuto():New( "ADODB.Recordset" )
oRsGs:CursorType := 1 // opendkeyset
oRsGs:CursorLocation := 3 // local cache
oRsGs:LockType := 3 // lockoportunistic
cSql := "Select * From [GroomService] "
cSql += "Where [BreedType] = 'Packages' "
cSql += "Order by [Breed]"
TRY
oRsGs:Open( cSQL,xCONNECT )
CATCH oErr
MsgInfo( "Error in Opening GROOMSERVICE table" )
RETURN(.F.)
END TRY
If oRsGs:eof
Else
oRsGs:MoveFirst()
// delete the first row
oRsGs:Delete()
oRsGs:Update()
Endif
oRsGs:Close()
oRsGs := nilRick Lipkin wrote:oRsGs:Delete() oRsGs:Update() Endif oRsGs:Close() oRsGs := nil
FUNCTION Delete( oRs )
LOCAL n
if MsgYesNo( "¿ Desea BORRAR este Registro ?."+CRLF+CRLF+"Si tiene dudas, seleccione No.", " B O R R A R R E G I S T R O" )
if oRs:RecordCount() = 0
MsgAlert("ERROR: No hay ningún registro en la tabla."+CRLF+CRLF+"No hay nada que BORRAR.", " E R R O R ")
RETURN NIL
endif
n := oRs:AbsolutePosition
oRs:Delete()
oRs:Update()
if !oRs:RecordCount() = 0
oRs:AbsolutePosition := Min( n, oRs:RecordCount() )
endif
MsgInfo("El Registro ha sido BORRADO correctamente.", " A V I S O ")
else
MsgInfo("El USUARIO ha cancelado la operación de Borrar.", " A V I S O ")
endif
RETURN NIL
//----------------------------------------------------------------------------//elvira wrote:oRs:Delete() oRs:Update()
elvira wrote:That is what I want to control with locks.
//-----------------
Static FUNCTION _RateDel( oRsTaxRate,oLbxB )
LOCAL SAYING, cSQL, oERR, cNAME
IF xSUPER = 'Y'
ELSE
SAYING := "Sorry ... You have READ only Rights"
Msginfo( SAYING )
RETURN(.F.)
ENDIF
IF oRsTaxRate:EOF
SAYING := "Sorry ... Before you can Delete a "
SAYING += "record, you have to Add one first"
Msginfo( SAYING )
RETURN(.F.)
ENDIF
cNAME := oRsTaxRate:Fields("Description"):Value
SAYING := "Are you SURE you want to Delete this record for "+CHR(10)
SAYING += alltrim(cNAME)+CHR(10)
IF MsgYesNO( SAYING )
ELSE
RETURN(.F.)
ENDIF
Try
oRsTaxRate:Delete()
Catch
MsgInfo( "Deletion failed" )
Return(.f.)
End Try
TRY
oRsTaxRate:MoveNext()
CATCH
END TRY
IF oRsTaxRate:eof .and. .not. oRsTaxRate:bof
TRY
oRsTaxRate:MoveFirst()
CATCH
END TRY
ENDIF
oLbxB:ReFresh()
RETURN(NIL)Static FUNCTION _RateDel( oRsTaxRate,oLbxB )
LOCAL SAYING, cSQL, oERR, cNAME
IF xSUPER = 'Y'
ELSE
SAYING := "Sorry ... You have READ only Rights"
Msginfo( SAYING )
RETURN(.F.)
ENDIF
IF oRsTaxRate:EOF
SAYING := "Sorry ... Before you can Delete a "
SAYING += "record, you have to Add one first"
Msginfo( SAYING )
RETURN(.F.)
ENDIF
cNAME := oRsTaxRate:Fields("Description"):Value
SAYING := "Are you SURE you want to Delete this record for "+CHR(10)
SAYING += alltrim(cNAME)+CHR(10)
IF MsgYesNO( SAYING )
ELSE
RETURN(.F.)
ENDIF
Try
oRsTaxRate:Delete()
Catch
MsgInfo( "Deletion failed" )
// two possible options
// option 1
* oRsTaxRate:Requery()
// or close the recordset and reopen without re-initializing the
// recordset variable
oRsTaxRate:Close()
cSQL := "SELECT * FROM [jTax Sets] order by NAME" // original query
TRY
oRsTaxSet:Open( cSQL,xCONNECT )
CATCH oErr
// hope this never happens .. going to blow chunks
MsgInfo( "Error in Opening jTax Sets table" )
RETURN(.F.)
END TRY
IF oRsTaxRate:eof .and. .not. oRsTaxRate:bof
TRY
oRsTaxRate:MoveFirst()
CATCH
END TRY
ENDIF
oLbxB:ReFresh()
Return(nil)
End Try
TRY
oRsTaxRate:MoveNext()
CATCH
END TRY
IF oRsTaxRate:eof .and. .not. oRsTaxRate:bof
TRY
oRsTaxRate:MoveFirst()
CATCH
END TRY
ENDIF
oLbxB:ReFresh()
RETURN(NIL)Thank you so much.
I am going to test with Requery() and share the results.
Also, how can I made two relations?
SET RELATION TO ADDRESS->REGISTRO INTO CUSTOMER, TO ADDRESS->REG_USUARI INTO ITEMS
So as I can do the following:
SELECT("ADDRESS")
DBGOTO(10)
?CUSTOMER->NAME
?ITEMS->NAME
Thank you very very much. You are helping me very much and very quick also, to learn and use Ado.
elvira wrote:Thank you so much.
I am going to test with Requery() and share the results.
Also, how can I made two relations?
SET RELATION TO ADDRESS->REGISTRO INTO CUSTOMER, TO ADDRESS->REG_USUARI INTO ITEMS
So as I can do the following:
SELECT("ADDRESS")
DBGOTO(10)
?CUSTOMER->NAME
?ITEMS->NAME
Thank you very very much. You are helping me very much and very quick also, to learn and use Ado.
elvira wrote:Also, how can I made two relations?
SELECT * FROM Address, Customer WHERE Address.Id = Customer.IdoRs:Fields( "Name" ):ValueMarc Vanzegbroeck wrote:For the deletion you can also execute the query 'DELETE FROM tabel WHERE ID = idnr'
Then you don't get an error if it is already deleted by someone else.
Thank you very much, great solution!.
Also, how do you make the bakcups to the database via SQL command?.
Thanks.
You are correct on the Delete followed by update .. I went back and looked at some of my code and I do not use update and I do try to trap a possible error with try\catch\end try.
unction RsDelete( oBrw )
local oRs := oBrw:oRs
local tmp
local lDeleted := .f.
if oRs:RecordCount() > 0
tmp := oRs:AbsolutePosition
oRs:Delete()
oRs:Update()
oRs:AbsolutePosition := Max( 1, Min( tmp, oRs:RecordCount() ) )
lDeleted := .t.
oBrw:Refresh()
endif
return lDeletedThank you very much.
And which is the best way to back up tables via an SQL COMMAND?.
SOmething like EXPORT or APPEND TO.
Thannks
.
I am not clear on this: if you do a oRS:delete() does it just delete the record in the recordset or does it automatically delete the record in the table on the server too? Or, is the record in the table only deleted when the recordset is updated (oRS:update())?
James
I am not clear on this: if you do a oRS:delete() does it just delete the record in the recordset or does it automatically delete the record in the table on the server too? Or, is the record in the table only deleted when the recordset is updated (oRS:update())?
James