Ver Mensaje Individual
  #1  
Antiguo 19-12-2009
ehdez82 ehdez82 is offline
Miembro
 
Registrado: dic 2009
Posts: 13
Reputación: 0
ehdez82 Va por buen camino
clientdataset error No key specified

Hola tengo un CDS con un ADODataSet detrás que tiene la siguiente consulta:

Código SQL [-]SELECT `embalaje_item`.* FROM `embalaje_item` WHERE `embalaje_item`.`embalajeId` = :id_Embalaje AND `embalaje_item`.`ventaId` = :id_Venta;


En esta tabla el campo llave es "idEmbalajeItem". En el CDS le tengo activado en el ProviderFlags la marca pfInKey. Sin embargo me arroja un error de "Unable to find record. No key specified".

Específicamente falla porque en el método UseFieldInWhere no encuentra el valor en la línea seleccionada. Al no poder incluir ningún campo el método: Provider.TSQLResolver.GenWhereSQL($1C509E0,$1C2FF90,$1B341C8,upWhereKeyOnly,'') lanza un error de SNoKeySpecified.

Código:
function TSQLResolver.UseFieldInWhere(Field: TField; Mode: TUpdateMode): Boolean;
const
  ExcludedTypes = [ftDataSet, ftADT, ftArray, ftReference, ftCursor, ftUnknown];
begin
  with Field do
  begin
    Result := not (DataType in ExcludedTypes) and not IsBlob and
      (FieldKind = fkData) and (Tag <> tagSERVERCALC);
    if Result then
      case Mode of
        upWhereAll:
          Result := pfInWhere in ProviderFlags;
        upWhereChanged:
          Result := ((pfInWhere in ProviderFlags) and not VarIsClear(NewValue)) or
            (pfInKey in ProviderFlags);
        upWhereKeyOnly:
          Result := pfInKey in ProviderFlags;
      end;
  end;
end;
Alguna idea de como puede perder el valor pfInKey. He probado ponerlo por código pero nada. Los datos se refrescan con el siguiente código:


Código:
with dm_Ventas.ds_VentaItems do
    begin
      Parameters.ParamByName('id_Embalaje').Value := IntToStr(id_Embalaje);
      Parameters.ParamByName('id_Venta').Value := '0';
      Active:= False;
      Active:= True;
    end;
    dm_Ventas.cds_VentaItems.Refresh;
¿Es posible que cerrar y abrir el dataset provoque la perdida del valor pfInKey?

Gracias de antemano.
salu2.
Responder Con Cita