NOTE:
- I use direct ado components
- The recordset is send and recieved with Optimistic batch and disconnected...
- I use client cursors
- I try using static, dynamic and keyset cursor...
- Using Sql Server 2000
I get the follow error "Row cannot be located for updating. Some values may have been changed since it was last read.." when this things happend:
1- Insert a new record and post it. Then change some values of this and post again. Here i get the error.
2- The recordset is join-based. I workaround this removing the join and use functions....
The 1 is my priority problem. I try usign Properties['Update Criteria'].value :=adCriteriaKey, but not work.
Also, i try using the resync command with several combinations and thisd not work.
This is the source (all recordset get the data from sp)
CREATE PROCEDURE spObtenerAreas
@plcFiltro VARCHAR(100)=NULL,-- Filtro
@plcOrden VARCHAR(100)=NULL
AS
DECLARE @lcSql NVARCHAR(300)
SET @lcSql='SELECT dbo.Areas.* FROM dbo.Areas'
--Tiene filtro?
IF @plcFiltro IS NOT NULL
SET @lcSql=@lcSql+' WHERE ('+@plcFiltro+')'
-- Tiene orden?
IF @plcOrden IS NULL
SET @plcOrden='Areas.PeriodoAcademico DESC,Areas.Nombre'
SET @lcSql=@lcSql+' ORDER BY '+@plcOrden
--Ejecutar la consulta
EXEC sp_ExecuteSql @lcSql
GO
plcOrden is the custom ORDER BY list of fields
plcFilter is the custom WHERE clause (ex: PeriodoAcademico='2001')
The pseudocode for the updating:
1- I recieve the recordset from a adoDataset using a command object, becuse a need a update recordset. That is:
adoDataset.Open(adoCommand,adoConnection)
adoCommand is configured with the parameters, too...
2- I change the data, add records and delete records in the client (but the error is only with add records)
3- Send the recordset, and loop for the changed record and do adoDataSet.UpdateBatch(adAffectCurrent) (I need it and not UpdateBatch(all) because a need know the actual record...
4- First Update is ok, return the recordset to the client
5- Then, i change some fields for the new record. (No id, of course)
6- The step 3 is repeated, but the new record faild.
7- I'm crazy!
Any ideas?
The Life is Beautiful!
Programmer in
Delphi, VS.NET
MCP