pmaster Posted December 6, 2009 at 05:43 PM Report Share #298934 Posted December 6, 2009 at 05:43 PM Boa tarde a todos Pessoal é o seguinte, eu tenho 2 timepikers e uso-os como referencia, para fazer uma query que é a seguinte: sql = "Select * from movi where dataop >= # " & DateTimePicker1.Text & " # and dataop <= # " & DateTimePicker2.Text & " # ORDER BY dataop ASC;" Mas esta query nao me retorna nada, e já me sentifiquei que tenho dados na base de dados. Alguem me pode ajudar? Obrigado 😉 Link to comment Share on other sites More sharing options...
bruno1234 Posted December 6, 2009 at 05:54 PM Report Share #298935 Posted December 6, 2009 at 05:54 PM Vê em debug como fica a variável sql depois de ter sido afectada com os valores dos datetime pickers e mostra aqui o resultado. Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
pmaster Posted December 6, 2009 at 06:00 PM Author Report Share #298939 Posted December 6, 2009 at 06:00 PM Já tive o cuidado de ver como fica em debug, testei agora de novo e fica da seguinte maneira: dataop <= # 03-12-2009 # and dataop >= # 06-12-2009 # Desde já obrigado 😉 Link to comment Share on other sites More sharing options...
bruno1234 Posted December 6, 2009 at 06:08 PM Report Share #298940 Posted December 6, 2009 at 06:08 PM E se executares a query directamente na base de dados, funciona? Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
pmaster Posted December 6, 2009 at 06:11 PM Author Report Share #298941 Posted December 6, 2009 at 06:11 PM Eu faço sempre da seguinte maneira.. Não entendo é porque razão nao consigo realizar esta pesquisa. sql = "Select * from movi where dataop >= # " & DateTimePicker1.Text & " # and dataop <= # " & DateTimePicker2.Text & " # ORDER BY dataop ASC;" da.SelectCommand.CommandText = sql ds.Clear() da.Fill(ds, "movi") Link to comment Share on other sites More sharing options...
pmaster Posted December 6, 2009 at 06:55 PM Author Report Share #298947 Posted December 6, 2009 at 06:55 PM Não sei se ajuda, mas por exemplo se eu tiver 2 registo, um no dia 3-12-09 e outro no dia 4-12-09 Se escolher datas do genero, entre 15-11-09 2 30-12-09, ele já me retorna os registos. Link to comment Share on other sites More sharing options...
FreiNando Posted December 6, 2009 at 11:27 PM Report Share #298996 Posted December 6, 2009 at 11:27 PM Tenta formatar a Data para o formato internacional "YYYY-MM-DD", ou para o sistema Americano "MM-DD-YYYY". Acontece que na data "30-12-2009" o mês 30 não existe e o sistema busca um formato possivel, neste caso o "DD-MM-YYYY". O caminho mais curto para conseguir fazer muitas coisas é fazer uma de cada vez. Samuel Smiles Link to comment Share on other sites More sharing options...
Pwyll Posted December 7, 2009 at 04:03 AM Report Share #299025 Posted December 7, 2009 at 04:03 AM Já tive o cuidado de ver como fica em debug, testei agora de novo e fica da seguinte maneira: dataop <= # 03-12-2009 # and dataop >= # 06-12-2009 # Desde já obrigado 😉 Que data é que é menor ou igual a 3-12-2009 e ao mesmo tempo maior ou igual a 6-12-2009 ? Eu nao conheco nenhuma, se nao esta a retornar nada quer dizer que esta a fazer bem 😞 Link to comment Share on other sites More sharing options...
pmaster Posted December 7, 2009 at 09:27 AM Author Report Share #299029 Posted December 7, 2009 at 09:27 AM PWLL obrigado por me chamares à atenção.. Eu escrevi mal aqui no forum, mas no programa tenho escrito acho que correctamente. Fica a correcção. dataop >= # 03-12-2009 # and dataop <= # 06-12-2009 # Obrigado 😉 Link to comment Share on other sites More sharing options...
pmaster Posted December 8, 2009 at 05:44 PM Author Report Share #299302 Posted December 8, 2009 at 05:44 PM Consegui resolver o problema. Fiz com o FreiNando disse, transformei a data em sistema Americano "MM-DD-YYYY" e funcionou na perfeição. Obrigado. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now