ApplyUpdates(0)
Estou desenvolvendo um aplicativo simple com Firebird e DBExpress, ao tentar realizar o ApplyUpdates(0) do ClientDataSet de lançamentos efetuados em grid recebo a seguinte menssagem : unabled to find record. No key specifiend.
Será que alguem pode me ajudar?
Grato.
Será que alguem pode me ajudar?
Grato.
Macbertocco
Curtidas 0
Respostas
Farore
01/05/2003
Você colocou algum tipo de gerador de chave primária?
Se for isto retorne que eu te digo como clocar.
Se for isto retorne que eu te digo como clocar.
GOSTEI 0
Macbertocco
01/05/2003
Sim coloquei segue abaixo:
function Tdatm_CadastroApartamentos.GetMaxSeqApartamento(NApto : integer): integer;
begin
SQL_Work.Close;
SQL_Work.SQL.Clear;
SQL_Work.SQL.Add(´Select Max(LI_SEQNUMEROAPTO) As NSeqApto´);
SQL_Work.SQL.Add(´From Apartamentos´);
SQL_Work.SQL.Add(´Where LI_NUMEROAPTO =´+IntToStr(NApto));
SQL_Work.Open;
Result := SQL_Work.FieldByName(´NSeqApto´).AsInteger;
end;
procedure Tdatm_CadastroApartamentos.CDS_ApartamentosBeforePost(
DataSet: TDataSet);
begin
inherited;
if CDS_Apartamentos.State in [dsInsert] then begin
CDS_Apartamentos.FieldByName(´LI_SEQNUMEROAPTO´).AsInteger := GetMaxSeqApartamento(CDS_Apartamentos.FieldByName(´LI_NUMEROAPTO´).AsInteger)+1;
end;
end;
function Tdatm_CadastroApartamentos.GetMaxSeqApartamento(NApto : integer): integer;
begin
SQL_Work.Close;
SQL_Work.SQL.Clear;
SQL_Work.SQL.Add(´Select Max(LI_SEQNUMEROAPTO) As NSeqApto´);
SQL_Work.SQL.Add(´From Apartamentos´);
SQL_Work.SQL.Add(´Where LI_NUMEROAPTO =´+IntToStr(NApto));
SQL_Work.Open;
Result := SQL_Work.FieldByName(´NSeqApto´).AsInteger;
end;
procedure Tdatm_CadastroApartamentos.CDS_ApartamentosBeforePost(
DataSet: TDataSet);
begin
inherited;
if CDS_Apartamentos.State in [dsInsert] then begin
CDS_Apartamentos.FieldByName(´LI_SEQNUMEROAPTO´).AsInteger := GetMaxSeqApartamento(CDS_Apartamentos.FieldByName(´LI_NUMEROAPTO´).AsInteger)+1;
end;
end;
GOSTEI 0