Jump to content
Fórum Script Brasil
  • 0

Nome Do "data Source" Longo Demais?


marcos_804

Question

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 = valor

end function

key = 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 by dark0
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

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"
%>

Link to comment
Share on other sites

  • 0

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 = valor

end function

key = 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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...