Opa, olha eu aki de novo com outro problema de SQL, rsrsrsrsrsrsrs Tenho um projeto de estudo aki que funciona tudo direitinho, menos a colsulta ela não gera nenhum erro no cod da consulta contudo não estou conseguindo fazer com que o rsult da consulta apareça num DBGrid, me ajudem ai please :)
o cod da unit: unit UCadContatos; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Mask, DBCtrls, DB, DBTables, Grids, DBGrids, ExtCtrls, Buttons; type TFrm_Contatos = class(TForm) GroupBox1: TGroupBox; Table1: TTable; DataSource1: TDataSource; Table1Cod: TAutoIncField; Table1Nome: TStringField; Table1Telefone: TStringField; Table1Email: TStringField; Table1DataCad: TDateField; Label1: TLabel; DBEdit1: TDBEdit; Label2: TLabel; DBEdit2: TDBEdit; Label3: TLabel; DBEdit3: TDBEdit; Label4: TLabel; DBEdit4: TDBEdit; Label5: TLabel; DBEdit5: TDBEdit; DBNavigator1: TDBNavigator; DBGrid1: TDBGrid; GroupBox2: TGroupBox; DBGrid2: TDBGrid; qryConsultaSqlNomeIntervalo: TQuery; RdGrpOpcoes: TRadioGroup; Lbldigitenome: TLabel; Lbldataini: TLabel; Lbldatafim: TLabel; Edtnomesql: TEdit; Mskdtdtini: TMaskEdit; Mskdtdtfim: TMaskEdit; btConsultaSqlNomeIntervalo: TBitBtn; DataSource2: TDataSource; procedure RdGrpOpcoesClick(Sender: TObject); procedure btConsultaSqlNomeIntervaloClick(Sender: TObject); procedure Table1AfterPost(DataSet: TDataSet); private { Private declarations } public { Public declarations } end; var Frm_Contatos: TFrm_Contatos; implementation {$R *.dfm} procedure TFrm_Contatos.RdGrpOpcoesClick(Sender: TObject); begin with RdGrpOpcoes do begin //se o tipo de pesquisa for por nome if ItemIndex = 0 then begin Edtnomesql.Enabled := true; Mskdtdtini.Enabled := false; Mskdtdtfim.Enabled := false; end //se o tipo de pesquisa for por datas else if ItemIndex = 1 then begin Edtnomesql.Enabled := false; Mskdtdtini.Enabled := true; Mskdtdtfim.Enabled := true; end //caso não seja definido o tipo de pesquisa else begin Edtnomesql.Enabled := false; Mskdtdtini.Enabled := false; Mskdtdtfim.Enabled := false; end; end; end; procedure TFrm_Contatos.btConsultaSqlNomeIntervaloClick(Sender: TObject); begin if RdGrpOpcoes.ItemIndex = 0 then begin //pesquisa por nome with qryConsultaSqlNomeIntervalo do begin close; sql.Clear; sql.Add('select * from Contatos'); sql.Add('where nome like :nomep'); ParamByName('nomep').Value := Edtnomesql.Text + '%'; open; if IsEmpty then begin ShowMessage('Este nome não existe, tente outra vez!'); Edtnomesql.SetFocus; Edtnomesql.Clear; end; end; end else if RdGrpOpcoes.ItemIndex = 1 then begin with qryConsultaSqlNomeIntervalo do begin close; sql.Clear; sql.Add('select * from Contatos'); sql.Add('where DataCad between :dtini and :dtfim'); ParamByName('dtini').Value := strtodate(Mskdtdtini.Text); ParamByName('dtfim').Value := strtodate(Mskdtdtfim.Text); open; if IsEmpty then begin ShowMessage('Não existe contatos cadastrados com este intervalo de datas, tente outra vez!'); Mskdtdtini.SetFocus; Mskdtdtini.Clear; Mskdtdtfim.Clear; end; end; end else begin ShowMessage('Selecione o tipo de pesquisa'); RdGrpOpcoes.SetFocus; end; end; procedure TFrm_Contatos.Table1AfterPost(DataSet: TDataSet); begin Table1.CommitUpdates; end; end. Espero pela força de sempre do pessoal ai do grupo :) Grato