List the daily records?

Asked

Viewed 128 times

1

My program does the insertion of records of both the services and the computers of a school library. As such the library office has to make a daily record and I would like to know if it is possible to list only the daily requests (services or computers)?

inserir a descrição da imagem aqui

The goal was me through the textbox with the time of the system to be able to list all requests made on the day itself, whether it was in Listview or Datagrid, however the code I have listed all requests made in the BD.

inserir a descrição da imagem aqui

The way to insert the requests is:

inserir a descrição da imagem aqui

The boot code "keep"

inserir a descrição da imagem aqui

  • How you are populating the Datagrid?

  • @Maiconcarraro populando?

  • How to fill in Datagrid data when clicked on Save?

  • @Maiconcarraro I edited, it’s on top. Make the entry in the service register and then in the listing it is supposed to appear only the records made on such a day.

  • I mean, when you click Guardar how do you search the data? It is by SqlCommand ?

  • @Maiconcarraro is yes

  • You can put the code in your question for easy resolution?

  • I do not understand very well how the informed schedule will affect the query if you want to list all of the day, but for that you can change your sql for SELECT * FROM Requisição WHERE dataRequisicao >= Convert(date, getdate())

  • @Maiconcarraro I had already tried the select with a Where but not with Convert(date, getdate()) I used your select and got what I wanted, thank you!

  • @Maiconcarraro With the code that my colleague and I have, after clicking on the save button everything is as we want, but when we leave and re-enter the application, the saved data disappears. Is there any way to keep them? Thank you.

Show 5 more comments

2 answers

0


I believe your correct SQL is this one:

SELECT Requisição.dataRequisicao, 
       Requisição.codRequisicao, 
       Utilizadores.numProcesso, 
       Utilizadores.nomeUtilizador, 
       Turma.Ano, 
       Turma.Turma, 
       Turma.Curso 
FROM Requisição 
INNER JOIN TipoServiço ON Requisição.codTpServico = TipoServiço.codTpServico
INNER JOIN Utilizadores ON Requisição.numProcesso = Utilizadores.numProcesso
INNER JOIN TpUtilizador ON Utilizadores.CodUtilizador = TpUtilizador.CodUtilizador 
INNER JOIN Turma ON Utilizadores.codTurma = Turma.codTurma 
WHERE (Convert(date, Requisição.dataRequisicao) = Convert(date, getdate()))

What you posted in the comments is with several syntax errors, missing = and with () further, then I advise testing before on Sqlserver.

0

First this so-called "save" or technically known as insertion command is confused by the fact that its command is a "Select * from...." Just populating the grid in the nail ? as for the listing, to be able to list all your records according to the current date just include a Where clause ..

"Select * from requisicao where(dataRequisicao = getDate())"

(Obs: For good programming practices it is not advisable to give names to tables, procedures, views, etc with accentuation)

  • Jeferson, I may be wrong, but this one SELECT has no problem with schedules?

  • Time problems? refers to the fact that the value returned by the methodgetDate() not being in the same format with the saved in the records?

  • Exactly, by the fact of the dateI want to be DATETIME believe that influences this =, nay?

  • No, because the value returned by the method is of type datetime, only care to be taken and to see the current language, because the return brings the date in format according to the same.

  • Hence the problem, the method returns current time and it wants any time of today.

  • The method returns both time and current date

  • Yes, but his SELECT will do something like WHERE ('11/06/2015 14:38:49' = '11/06/2015 15:27:32') and will not return :)

  • Oh yes , as I said it is necessary to see the format of both dates , however this is an easy adjustment :)

  • As I said in the comments of the question, I recommend casting to transform the dataRequisicao in date and with operator ">=". Example

  • Yes, but the ">" operator becomes kind of useless since there will never be a record with a higher date than the current one is not even ? rs

  • i tried using the following select with Inner Join and gives 1 error: "SELECT Requisição.dataRequisicao, Requisição.codRequisicao, Utilizadores.numProcesso, Utilizadores.nomeUtilizador, Turma.Ano, Turma.Turma, Turma.Curso"

"FROM Requisição INNER JOIN"
"TipoServiço ON Requisição.codTpServico TipoServiço.codTpServico INNER JOIN"
"Utilizadores ON Requisição.numProcesso Utilizadores.numProcesso INNER JOIN"
"TpUtilizador ON Utilizadores.CodUtilizador TpUtilizador.CodUtilizador INNER JOIN"
"Turma ON Utilizadores.codTurma = Turma.codTurma"
"WHERE(Requisição.dataRequisicao >= Convert(Of Date, GETDATE())())"

  • @Maiconcarraro when I use your select alone gives good when I try to do the Inner Join to get data in the datagrid of other tables appears an error

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.