duvida
Ola estou com a seguinte duvida quero fazer um select na minha tabela de nota onde se o usuario tentar cadastrar uma nota com um numero que ja foi cadastrado o sistema retorne a nota que esta no banco de dados, tentei fazer assim!
procedure Tcadastronotas.DBEdit2Exit(Sender: TObject);
begin
inherited;
if ds.dataset.State in [dsedit, dsinsert] then
begin
if dbedit2.Field.AsString<>'' then
begin
deasy.cdsnota.CommandText:='select * from nota where numeronota =:nota';
deasy.cdsnota.Params.ParamByName('nota').AsString:=dbedit2.Field.AsString;
end;
end;
end; nao obtive sucesso O.o!!
begin
inherited;
if ds.dataset.State in [dsedit, dsinsert] then
begin
if dbedit2.Field.AsString<>'' then
begin
deasy.cdsnota.CommandText:='select * from nota where numeronota =:nota';
deasy.cdsnota.Params.ParamByName('nota').AsString:=dbedit2.Field.AsString;
end;
end;
end; nao obtive sucesso O.o!!
Paulo Silva
Curtidas 0
Respostas
Ricardo Boaro
23/01/2009
Olá
Vc fez dessa forma:
procedure Tcadastronotas.DBEdit2Exit(Sender: TObject);
begin
inherited;
if ds.dataset.State in [dsedit, dsinsert] then
begin
if dbedit2.Field.AsString<>'' then
begin
deasy.cdsnota.CommandText:='select * from nota where numeronota =:nota';
deasy.cdsnota.Params.ParamByName('nota').AsString:=dbedit2.Field.AsString;
end;
end;
end; Altere para:
procedure Tcadastronotas.DBEdit2Exit(Sender: TObject);
begin
inherited;
if ds.dataset.State in [dsedit, dsinsert] then
begin
if dbedit2.Field.AsString<>'' then
begin
if deasy.cdsnota.locate(NumeroNota, DbEdit2.text,[]) then // se localizar é por q a nota existe e se existir ja aparecerá na tela, pois com o Locate paramos o cursos da tabela exatamente na nota passada como parametro no DbEdit2.text.
end;
end;
end;
Faça o teste e retorne por favor.
Abraço
Vc fez dessa forma:
procedure Tcadastronotas.DBEdit2Exit(Sender: TObject);
begin
inherited;
if ds.dataset.State in [dsedit, dsinsert] then
begin
if dbedit2.Field.AsString<>'' then
begin
deasy.cdsnota.CommandText:='select * from nota where numeronota =:nota';
deasy.cdsnota.Params.ParamByName('nota').AsString:=dbedit2.Field.AsString;
end;
end;
end; Altere para:
procedure Tcadastronotas.DBEdit2Exit(Sender: TObject);
begin
inherited;
if ds.dataset.State in [dsedit, dsinsert] then
begin
if dbedit2.Field.AsString<>'' then
begin
if deasy.cdsnota.locate(NumeroNota, DbEdit2.text,[]) then // se localizar é por q a nota existe e se existir ja aparecerá na tela, pois com o Locate paramos o cursos da tabela exatamente na nota passada como parametro no DbEdit2.text.
end;
end;
end;
Faça o teste e retorne por favor.
Abraço
GOSTEI 0
Paulo Silva
23/01/2009
if ds.DataSet.State in [dsedit, dsinsert] then
begin
if dbedit5.Text<>'' then
begin
if ds.DataSet.Locate('numeronota', dbedit5.text,[]) then
TClientDataSet(ds.dataset).CancelUpdates;
end;
end;
end; fiz assim e funcionou perfeitamente valeu, brigadao!
begin
if dbedit5.Text<>'' then
begin
if ds.DataSet.Locate('numeronota', dbedit5.text,[]) then
TClientDataSet(ds.dataset).CancelUpdates;
end;
end;
end; fiz assim e funcionou perfeitamente valeu, brigadao!
GOSTEI 0