Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

claytonprog

[Resolvido] Consulta com combo

Recommended Posts

Pessoal tenho esse codigo aqui não dá erro mais também não me retorna nada. Alguem pode dizer onde eu errei!!!!

 

ASP
<%

' Declare our variables... always good practice!

Dim strURL     ' The URL of this page so the form will work

               ' no matter what this file is named.

 

Dim cnnSearch  ' ADO connection

Dim rstSearch  ' ADO recordset

Dim strDBPath  ' path to our Access database (*.mdb) file

 

Dim strSQL     ' The SQL Query we build on the fly

Dim strSearch  ' The text being looked for

 

 

strSearch = Request.QueryString("search")

 

%>

<p> </p>

<table width="41%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F5F5FA">

<tr>

    <td><p align="center"><FONT color=royalblue face=Tahoma size=2><STRONG><font color="#000033">

        :: Selecione o Docente :</font>:</STRONG></FONT></p>

      <form action="<%= search %>" method="get">

        <div align="center">

          <select name="Search" class="formula1" style="width:150" >

                                        <option value="Todos">Todos</option>

<%

Response.Expires = -1

 

Dim objConnCur, stringSQL

 

Set objConnCur =  Server.CreateObject("ADODB.Connection")

Set objRSCur =  Server.CreateObject("ADODB.Connection")

 

objConnCur.Open "DBQ=" & Server.MapPath("painel/db/docentes.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"

 

stringSQL = "SELECT id_docente, login FROM Tbldocentes ORDER BY login ASC"

 

Set objRSCur = objConnCur.Execute(stringSQL)

 

While not objRSCur.eof

%>

<option value="<%=objRSCur("id_docente")%>"><%=objRSCur("login")%></option>

<%

        objRSCur.MoveNext

Wend

objRSCur.Close

%>

 

</select>

         

          <input name="submit" type="submit" value="Pesquisar" />

        </div>

      </form>

      <p align="center">

        <%

If strSearch <> "" Then

       

        strDBPath = Server.MapPath("painel/db/downloads_professor.mdb")

       

        Set cnnSearch = Server.CreateObject("ADODB.Connection")

 

       

        cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"

       

        'cnnSearch.Open Application("SQLConnString")

 

                               

    strSQL = "SELECT * from tblarquivos where professor ='"&strSearch&"'"

 

       

        Set rstSearch = cnnSearch.Execute(strSQL)

 

                %>

      </p>

      <div align="center">

        <table border="0" cellpadding="4" cellspacing="1" width="403">

          <tr>

            <th bgcolor="#6699CC"><FONT color=royalblue face=Tahoma size=2><STRONG><font color="#000033">::

              Professor :</font>:</STRONG></FONT></th>

            <th bgcolor="#6699CC" width="164"><FONT color=royalblue face=Tahoma size=2><STRONG><font color="#000033">::

              Arquivo:</font>:</STRONG></FONT></th>

           

          </tr>

          <%

        Do While Not rstSearch.EOF

                %>

          <tr>

            <td bgcolor="#D7F2FF"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><%= rstSearch.Fields("Login").Value %></font></td>

            <td bgcolor="#D7F2FF" width="164"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a href='painel/pdf/"<%= rstSearch.Fields("filename").Value %> "' target='_blank' style='font-color:#000000'><img src='images/downloads.gif' border='0'></a></font></div></td>

           

          </tr>

          <%

 

                rstSearch.MoveNext

        Loop

        %>

        </table>

        <%

       

        rstSearch.Close

        Set rstSearch = Nothing

        cnnSearch.Close

        Set cnnSearch = Nothing

End If

 

' That's all folks!  See it's really not all that hard.

%>

      </div></td>

  </tr>

</table>

<p> </p>

Compartilhar este post


Link para o post
Compartilhar em outros sites

pessoal desculpa ae! Esqueci de postar o codigo corrigido, porém vou me redimir segue abaixo espero que sirva pra alguém.<%' Declare our variables... always good practice!Dim strURL ' The URL of this page so the form will work' no matter what this file is named.Dim cnnSearch ' ADO connectionDim rstSearch ' ADO recordsetDim strDBPath ' path to our Access database (*.mdb) fileDim strSQL ' The SQL Query we build on the flyDim strSearch ' The text being looked forstrSearch = Request.QueryString("search")%><p> </p><table width="41%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F5F5FA"><tr><td><p align="center"><FONT color=royalblue face=Tahoma size=2><STRONG><font color="#000033">:: Selecione o Docente :</font>:</STRONG></FONT></p><form action="<%= search %>" method="get"><div align="center"><select name="Search" class="formula1" style="width:150" > <option value="Todos">Selecione</option><%Response.Expires = -1Dim objConnCur, stringSQLSet objConnCur = Server.CreateObject("ADODB.Connection")Set objRSCur = Server.CreateObject("ADODB.Connection")objConnCur.Open "DBQ=" & Server.MapPath("painel/db/docentes.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"stringSQL = "SELECT id_docente, login FROM Tbldocentes ORDER BY login ASC"Set objRSCur = objConnCur.Execute(stringSQL)While not objRSCur.eof%><option value="<%=objRSCur("login")%>"><%=objRSCur("login")%></option><% objRSCur.MoveNextWendobjRSCur.Close%></select> <input name="submit" type="submit" value="Pesquisar" /> </div></form><p align="center"><%If strSearch <> "" ThenstrDBPath = Server.MapPath("painel/db/downloads_professor.mdb")Set cnnSearch = Server.CreateObject("ADODB.Connection")cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"'cnnSearch.Open Application("SQLConnString")strSQL = "SELECT * from tblarquivos where professor ='"&strSearch&"'"Set rstSearch = cnnSearch.Execute(strSQL)%></p><div align="center"><table border="0" cellpadding="4" cellspacing="1" width="403"><tr><th bgcolor="#6699CC"><FONT color=royalblue face=Tahoma size=2><STRONG><font color="#000033">::Professor :</font>:</STRONG></FONT></th><th bgcolor="#6699CC" width="164"><FONT color=royalblue face=Tahoma size=2><STRONG><font color="#000033">::Arquivo:</font>:</STRONG></FONT></th></tr><%Do While Not rstSearch.EOF%><tr><td bgcolor="#D7F2FF"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><%= rstSearch.Fields("professor").Value %></font></td><td bgcolor="#D7F2FF" width="164"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a href='painel/pdf/<%= rstSearch.Fields("filename").Value %>' target='_blank' style='font-color:#000000'><img src='images/downloads.gif' border='0'></a></font></div></td></tr><%rstSearch.MoveNextLoop%></table><%rstSearch.CloseSet rstSearch = NothingcnnSearch.CloseSet cnnSearch = NothingEnd If' That's all folks! See it's really not all that hard.%></div></td></tr></table><p> </p>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.