ASP with SQL bringing different result of the query

Asked

Viewed 408 times

0

Good afternoon!

We are finishing a panel that will bring the results of an SQL in an ASP page. We already have two finished panels that are pulling the results perfectly. Only one of the panels does not bring the result with the SELECT we use, although when played in SQL SERVER returns the correct value. Only in ASP running that no. We tried some alternatives, but nothing. It follows excerpt of the code:

strSQL =          " SELECT count(solid) AS ENCERRADOS "
strSQL = strSQL & " FROM SOLICITACAO S "
strSQL = strSQL & " INNER JOIN USUARIO U ON (S.UsuIdReclamante  = U.UsuID) "
strSQL = strSQL & " INNER JOIN FilhoPai f on u.usuid = f.UsuIDFilho "
strSQL = strSQL & " INNER JOIN Usuario ux on ux.UsuID = f.UsuIDPai "
strSQL = strSQL & " INNER JOIN Usuario ur on ur.UsuID = s.UsuIDResponsavel "
strSQL = strSQL & " INNER JOIN Usuario ug on ur.usuIDGrupo = ug.usuID "
strSQL = strSQL & " WHERE SolData BETWEEN '2015-07-16 00:00:00' and '2015-07-16 23:59:59' "
strSQL = strSQL & " AND ug.usunome = 'Service Desk - 1º Nível TI' "
strSQL = strSQL & " AND s.usuidultimoresp = '2721184' "
strSQL = strSQL & " AND (SOLSTATUS IN ('7','9')) "

Set BUSCA3 = Server.CreateObject("ADODB.RecordSet")
BUSCA3.Open strSQL, Conexao, 1 

And where the result is displayed:

<p class="textoPainel"><%= BUSCA3("ENCERRADOS")%></p>

In the direct query in the database, returns 22 the value. In ASP returns 0.

  • The connection used in the page and the database pointed in the application is the same as in the database?

1 answer

1


I’m getting used to PHP language, but I’ve already touched classic ASP, its I remember, it was something like this:

<p class="textoPainel">
<%
if not BUSCA3.eof and not BUSCA3.bof then
    response.write(BUSCA3.fields("ENCERRADOS").value)
    BUSCA3.close
end if
%>
</p>

or

<p class="textoPainel"><%=BUSCA3.Fields("ENCERRADOS").Value; %></p>
  • I appreciate the help of all! We were able to finish the problem here. In case of interest to someone, the problem was in INNER JOIN! When we pulled out, it was OK.

Browser other questions tagged

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