Fórum Modelo de pesquisa e duvidas sobre o componente datasetprovider #9630
28/09/2009
0
[#VIDEO-153#]
Carlos Faria
Curtir tópico
+ 0Posts
28/09/2009
Carlos Faria
Gostei + 0
28/09/2009
Carlos Faria
Gostei + 0
28/09/2009
Carlos Faria
begin case rg.ItemIndex of
0:
begin
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where TELEFONE like :pTELEFONE';
Params.ParamByName('pTELEFONE').AsString := edtbusca.Text;
clientdataset.FetchParams ;
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
end;
1:
BEGIN
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where nome like :pnome';
Params.ParamByName('pnome').AsString := edtbusca.Text +'%';
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
END;
2:
BEGIN
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where ENDERECO like :pENDERECO';
Params.ParamByName('pENDERECO').AsString := edtbusca.Text +'%';
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
END;
3:
BEGIN
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where bairro like :pbairro';
Params.ParamByName('pbairro').AsString := edtbusca.Text +'%';
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
END;
4:
BEGIN
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where nome like :pnome and bairro like :pbairro';
Params.ParamByName('pnome').AsString := edtbusca.Text +'%';
Params.ParamByName('pbairro').AsString:= lblbairro.Text +'%';
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
END; end;
end; Acho que isso ai deve ser minha resposta ,falta apenas vc ver se esta ok dessa maneira e nao esquecer de me falar sobre o datasetprovider
Gostei + 0
29/09/2009
Rodrigo Mourão
Seu raciocio esta correto tem apenas uma pequenas mudancas de logica. Observe:
procedure TForm1.btnpesquisarClick(Sender: TObject);
begin case rg.ItemIndex of
0:
begin
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where TELEFONE like :pTELEFONE';
FetchParams
Params.ParamByName('pTELEFONE').AsString := edtbusca.Text;
clientdataset.FetchParams ;
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
end;
1:
BEGIN
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where nome like :pnome';
FetchParams
Params.ParamByName('pnome').AsString := edtbusca.Text +'%';
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
END;
2:
BEGIN
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where ENDERECO like :pENDERECO';
FetchParams
Params.ParamByName('pENDERECO').AsString := edtbusca.Text +'%';
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
END;
3:
BEGIN
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where bairro like :pbairro';
FetchParams
Params.ParamByName('pbairro').AsString := edtbusca.Text +'%';
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
END;
4:
BEGIN
with clientdataset do
begin
Close;
FetchParams ;
CommandText := 'select * from vw_cliente_2008 where nome like :pnome and bairro like :pbairro';
FetchParams
Params.ParamByName('pnome').AsString := edtbusca.Text +'%';
Params.ParamByName('pbairro').AsString:= lblbairro.Text +'%';
Open ;
lblTotal.Caption := IntToStr(ds.DataSet.RecordCount);
end;
END; end;
end;
Tire os codigos que eu risquei e acrescente os que estao em vermelho. Outra coisa pode ficar tranquilo que nao sobre carrega o datasetprovider nao pois esta é a ideia com clientedataset vc nao fica conectado direto. Os dados ficam off line por isso ele é tao bom e utilizado para grandes volumes de dados.
Abraços
Gostei + 0
29/09/2009
Carlos Faria
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)