marcos_804 Posted October 21, 2004 Report Share Posted October 21, 2004 (edited) AQUI VAI O QUE APARECE...Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Driver Manager] Data source name too long /teajudo/TesteDeBusca/search.asp, line 15<html><head><title>Busca - </title></head><body><%Function search( KEY ) valor = ""conn="DRIVER={Microsoft Access Driver (*.mdb)}; " conn=conn & "DBQ=" & server.mappath("banco.mdb") SQL = "SELECT FROM id, nome, email FROM banco WHERE(nome like '%" & KEY & "%') OR (email like '%" & KEY & "%')" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open conn, SQL DO while NOT rs.EOF valor = valor & "<b>nome:</b> " & rs(1) & "<br><b>Email: </b>" & rs(2) & "<br><br>" sr.MoveNext Loop rs.Close set rs = Nothing search = valorend functionkey = trim(request.form("KEY")) linhas = search( key )%><span style="font-family:verdana;font-size:12;color:#000000;height:15"><%=linhas%></span></body></html>Editado: Use a tag QUOTE para postar codigos com COLORAÇÃO! Edited October 21, 2004 by dark0 Quote Link to comment Share on other sites More sharing options...
0 bareta Posted October 21, 2004 Report Share Posted October 21, 2004 essa sua conexao ta meio estranha num ta não?você pode usar:<% Set conexao = Server.CreateObject("ADODB.Connection") conexao.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\banco.mdb" %> ou: <% Set conexao = Server.CreateObject("ADODB.Connection") conexao.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=c:\banco.mdb" %> Quote Link to comment Share on other sites More sharing options...
0 dark0 Posted October 21, 2004 Report Share Posted October 21, 2004 Se fosse EU, deixaria o codigo assim:<html><head><title>Busca - </title></head><body><%Function search( KEY ) valor = "" 'conecta ao banco url_conexao = Server.MapPath("banco.mdb") set conexao = Server.CreateObject("ADODB.Connection") conexao.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&url_conexao 'cria o SQL SQL = "SELECT FROM id, nome, email FROM banco WHERE(nome like '%" & KEY & "%') OR (email like '%" & KEY & "%')" 'Executa o SQL Set rs = conexao.execute(sql) DO while NOT rs.EOF valor = valor & "<b>nome:</b> " & rs(1) & "<br><b>Email: </b>" & rs(2) & "<br><br>" sr.MoveNext Loop rs.Close set rs = Nothing search = valorend functionkey = trim(request.form("KEY"))linhas = search( key )%><span style="font-family:verdana;font-size:12;color:#000000;height:15"><%=linhas%></span></body></html>Basicamente, eu alterei o que está colorido ..mas não testei aqui.. teste pra ver se serve.assim você sabe qual trecho faz a conexao, qual cria o sql, e qual executa ele!Um codigo organizado é melhor que um codigo maluco ..Ate mais Quote Link to comment Share on other sites More sharing options...
Question
marcos_804
AQUI VAI O QUE APARECE...
Editado: Use a tag QUOTE para postar codigos com COLORAÇÃO!
Edited by dark0Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.