Ir para conteúdo
Fórum Script Brasil
  • 0

[resolvido] Consulta Com Combo


claytonprog

Pergunta

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

<%
' 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>&nbsp;</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>&nbsp;</p>

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0
Guest Marcio Alves Vieira
<%

' 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>&nbsp;</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">

<%

Response.Expires = -1

Dim objConnCur, stringSQL

'Conexão HC ACCESS

'Set ObjConn=Server.CreateObject("ADODB.Connection")

'ObjConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=c:\inetpub\wwwroot\mexames\mexames.mdb"

'ObjConn.CursorLocation = 3

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

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

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

'ObjConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=c:\inetpub\wwwroot\mexames\mexames.mdb"

stringSQL = "SELECT * FROM tab_consulta"

Set objRSCur = objConnCur.Execute(stringSQL)

While not objRSCur.eof %>

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

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

<option value="seu_valor1"<% If ObjRSCur("seu_campo")="seu_valor1" Then Response.Write "selected"%>>seu_valor1</option>>

<option value="seu_valor2"<% If ObjRSCur("seu_campo")="seu_valor2" Then Response.Write "selected"%>>seu_valor2</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>&nbsp;</p>

Link para o comentário
Compartilhar em outros sites

  • 0

Gostaria de agradecer ao Márcio valeu mesmo mano ta funfando legal. ai está o codigo corrgido pra quem precisar.

<%
' 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>&nbsp;</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 = -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("login")%>"><%=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("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.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>&nbsp;</p>

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...