Fórum ApplyUpdates(0) #157246
01/05/2003
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
Curtir tópico
+ 0
Responder
Posts
01/05/2003
Farore
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.
Responder
Gostei + 0
03/05/2003
Macbertocco
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;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)