Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá, estou fazendo um trabalho da escola que preciso entregar até terça para poder pegar meu diploma de técnico. Este trabalho é um projeto de um sistema que eu fiz.
Meu problema é que estou na tela de relatório, e estou mandando pesquisar por data... no meu banco está com datetime os campos... sim, meus campos estão certos de acordo o código, o que acontece é que eu mando ele pesquisar entre uma data e outra (tipo = 01/10/2009 até 01/11/2009) e ele num acha nada... mas esse mesmo código no query do SQL dá certinho.
Vou postar o código do botão pesquisar para vocês verem se podem me ajudar.
begin
DBGrid1.Visible:=False;
with DM_Relatorio.ADOQuery_RelFestas do begin
SQL.Clear;
SQL.Add('Select Cli.IdCliente, Cli.NomeCliente,Dep.NomeDependente, FesXServ.DataInicial, ');
SQL.Add('FesXServ.DataFim, Serv.NomeServico, Mon.IdMonitor, Mon.NomeMonitor, ');
SQL.Add('Fes.IdFesta, Fes.ValorFesta, Fes.ObsFesta ');
SQL.Add('from Festas Fes');
SQL.Add('left join Clientes Cli On Cli.IdCliente = Fes.IdCliente');
SQL.Add('left join Dependentes Dep On Dep.IdDependente = Fes.IdDependente');
SQL.Add('left join FestasXServicos FesXServ On FesXServ.IdFesta = Fes.IdFesta');
SQL.Add('left join Servicos Serv On Serv.IdServico = FesXServ.IdServico');
SQL.Add('left join FestasXMonitores FesXMon On FesXMon.IdFesta = Fes.IdFesta');
SQL.Add('left join Monitores Mon On Mon.IdMonitor = FesXMon.IdMonitor');
SQL.Add('where 1 = 1 ');
if CheckCliente.Checked then begin
SQL.Add('and Cli.IdCliente = ' + mkCodCliente.Text );
RbClientes.Checked:= True;
end;
if CheckMonitor.Checked then begin
SQL.Add('and Mon.IdMonitor = ' + mkCodMonitor.Text );
RbMonitores.Checked:= True;
end;
if CheckPeriodo.Checked then begin
SQL.Add( 'and FesXServ.DataInicial >= ' + '"' + FormatDateTime( 'MM/DD/YYYY', StrToDate(mkPeriodoInicio.Text)) + '"');
SQL.Add( 'and FesXServ.DataFim <= ' + '"' + FormatDateTime( 'MM/DD/YYYY', StrToDate(mkPeriodoFim.Text )) + '"' );
RbData.Checked:= True;
end;
if RbData.Checked then
SQL.Add( ' order by FesXServ.DataInicial ' )
else if RbClientes.Checked then
SQL.Add( ' order by Cli.NomeCliente ' )
else if RbMonitores.Checked then
SQL.Add( ' order by Mon.NomeMonitor ' )
else if RbDependentes.Checked then
SQL.Add( ' order by Dep.NomeDependente ' );
Open;
end;
if (DM_Relatorio.ADOQuery_RelFestas.Eof) and (DM_Relatorio.ADOQuery_RelFestas.Bof) then begin
MessageDlg( ' Sua pesquisa não retornou nenhum registro ! ', mtWarning, [mbOk], 0 ) ;
Exit ;
End ;Carregando comentários...