Jump to content


Photo

[Resolvido] MigraçãO De Banco De Dados


  • Faça o login para participar
2 replies to this topic

#1 RF Programação

RF Programação

    Novato no fórum

  • Usuários
  • 7 posts
  • Sexo:Não informado

Posted 13/08/2009, 20:49

Eu tinha um sistema de busca entre datas no access e agora estou passando para MySQL, o problema é que está dando erro...

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[MySQL][ODBC 3.51 Driver][mysqld-5.1.31-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
/listagem.asp, line 75


<%
Session.LCID = 1046
hora = time()
%>
<%=Response.Write(hora)%>

<table><TR><TD  COLSPAN="4" ALIGN="CENTER" bgcolor="#ffffff"> </TD></TR>
<%
XXXPalavra = request.form("Palavra")
If Request.Form("Palavra")<>"" Then
	  dim dteInicial 
	  dteInicial = Request.Form("txtDataInicial")
	  dteInicial = Year(dteInicial) & "-" & Month(dteInicial) & "-" & Day(dteInicial)

	  dim dteFinal 
	  dteFinal = Request.Form("txtDataFinal")
	  dteFinal = Year(dteFinal) & "-" & Month(dteFinal) & "-" & Day(dteFinal)

Set conexao = CreateObject("ADODB.Connection")
abrir ="Driver={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=xxx; UID=xxx; PWD=xxx;"
conexao.open abrir
%>
<%
set rs = conexao.execute("SELECT DISTINCT * FROM Processos WHERE NOME like '%"+XXXPalavra+"%' and DATA between #" +  dteInicial + "# and #" + dteFinal + "# ORDER BY NOME ASC")
if rs.eof = TRUE then
%><br><br><br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">Nenhum registro !</font><br><br>
<% else 
Do While not rs.eof
%> 
<% ID= rs("ID") %>

<tr><TD bgcolor="#D3D3D3" width="154" background="img/fundo_barra.jpg" style="background-repeat:repeat-x">
<font face="Verdana" size="2" color="#000000">
<a href="resultado_consulta.asp?ID=<%=ID%>">
Proc. <% PROCESSO=rs("PROCESSO")%>
<% =rs("PROCESSO")%>
</a></font></TD>

<TD bgcolor="#D3D3D3" width="113" background="img/fundo_barra.jpg" style="background-repeat:repeat-x">
<font face="Verdana" size="2" color="#000000">
<% DATA=rs("DATA")%> (<% =DATA %>)
</font></TD>

<TD bgcolor="#D3D3D3" width="370" background="img/fundo_barra.jpg" style="background-repeat:repeat-x">
<font face="Verdana" size="2" color="#000000">
<% =rs("NOME") %>
<% NOME=rs("NOME") %>
</font></TD>

<TD bgcolor="#FFFFFF" width="57"><p>
<a href="deletar_processo.asp?id=<%=ID%>"><img src="img/excluir.gif" alt="excluir ítem" border="0"></a> 
<a href="adm_altera_processo.asp?id=<%=ID%>"><img src="img/modificar.gif" alt="modificar ítem" border="0"></a>
</TD></tr>

<tr><TD bgcolor="#F9F9F9" width="625" colspan="3" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px">
<font face="Arial,Verdana" size="2" color="#808080"><% ASSUNTO=rs("ASSUNTO")%><% =ASSUNTO%>
</font>
</TD>
<TD bgcolor="#FFFFFF" width="37"> </TD></tr>
<TR><TD width="625" colspan="3"> </TD>
<TD width="37"> </TD></tr>

<% 
rs.movenext
loop
end if 
end if
%>
</table>


Seria nessa parte o erro: :angry:
set rs = conexao.execute("SELECT DISTINCT * FROM Processos WHERE NOME like '%"+XXXPalavra+"%' and DATA between #" + dteInicial + "# and #" + dteFinal + "# ORDER BY NOME ASC")

Já estou batendo a cabeça...

Edição feita por: Renan L. Queiroz, 03/09/2009, 16:16.


#2 DeeK

DeeK

    Normal

  • Usuários
  • 63 posts
  • Sexo:Masculino

Posted 14/08/2009, 08:42

Cara,

Não é "+", é "&"

set rs = conexao.execute("SELECT DISTINCT * FROM Processos WHERE NOME like "'%" & XXXPalavra "%' and DATA between #"&dteInicial& "# and #" & dteFinal & "# ORDER BY NOME ASC")

no ASP é &

#3 RF Programação

RF Programação

    Novato no fórum

  • Usuários
  • 7 posts
  • Sexo:Não informado

Posted 14/08/2009, 23:52

Opa! Problema resolvido, o # é só no access que funciona, agora tá funcionado. Pode fechar o tópico!

Edição feita por: RF Programação, 14/08/2009, 23:53.





1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq