Jump to content

Archived

This topic is now archived and is closed to further replies.

dedindol

[Resolvido] Conexão

Recommended Posts

Olá galera,

To com um problema num sistema que to fazendo.

 

Tenho uma página que tem dois includes e ambos os includes tem um include do arquivo de conexão com o banco de dados My Sql,

 

quando tento executar a página no servidor aparece o seguinte erro:

 

Microsoft VBScript compilation error '800a0411'

 

Name redefined

 

/novo/adm/conexao.asp, line 4

 

dim conn

----^

Eu acho que o problema é que a variável está sendo declarada duas vezes, mas como posso resolver isso?

 

segue abaixo as minhas páginas:

 

arquivo de conexão:

conexao.asp

CODE
<%

 

if conn = false then

dim conn

End if

 

Sub AbreConn()

 

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

 

conn.Open = "Driver={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=db_noticia; UID=krcdesign; PWD=pe40vf;"

 

End Sub

 

 

Sub FechaConn()

 

conn.Close()

Set conn = Nothing

 

End Sub

 

%>

Página que tem os dois includes

index.asp

CODE
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> KRC Design - Criação de web sites, Design Digital e Design Gráfico </title>

<META NAME="Description" CONTENT="Empresa localizada em Santo André - SP, especializada em arquitetura e construções" />

<META NAME="Keywords" CONTENT="arquitetura construções design de interiores projetos casas prédios lojas buffets" />

<META NAME="Language" CONTENT="Portuguese" />

<META NAME="Author" CONTENT="KRC Design - www.krcdesign.com.br" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta name="robots" content="index,follow" />

<link href="inc/estilos.css" rel="stylesheet" type="text/css">

<script src="inc/flash1.js" type="text/javascript"></script>

<script src="inc/flash2.js" type="text/javascript"></script>

</head>

 

<body>

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="29" background="images/index_r3_c5.gif" class="login"> </td>

<td height="29" background="images/index_r3_c5.gif" class="login"><!--#include file="restrito.asp" --></td>

<td height="29" background="images/index_r3_c5.gif" class="login"> </td>

</tr>

<tr>

<td height="279" align="right" valign="top" background="images/fdo_topo_risco.jpg" class="login"> </td>

<td height="279" class="login"><script language="javascript">flash1();</script></td>

<td height="279" background="images/fdo_topo_risco.jpg" class="login"> </td>

</tr>

<tr>

<td height="100%" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="123" background="images/index_r11_c2.gif"> </td>

</tr>

<tr>

<td height="3"></td>

</tr>

<tr>

<td height="100%" background="images/index_r19_c2.gif"> </td>

</tr>

<tr>

<td height="39" background="images/index_r3_c5.gif"> </td>

</tr>

</table></td>

<td height="100%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="25" height="100%" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="123" background="images/index_r11_c2.gif"> </td>

</tr>

<tr>

<td height="3"></td>

</tr>

<tr>

<td height="100%" background="images/index_r19_c2.gif"> </td>

</tr>

<tr>

<td height="39" background="images/index_r3_c5.gif"> </td>

</tr>

</table></td>

<td width="14" height="100%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="100%" background="images/index_r11_c4.gif"> </td>

</tr>

<tr>

<td height="15"><img src="images/index_r35_c4.gif" width="14" height="15"></td>

</tr>

</table></td>

<td width="618" height="100%" align="left" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="100%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="604" height="199"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td height="22" colspan="7" valign="middle" background="images/index_r19_c2.gif" class="azul_marinho_bold"> Escolha o tipo de site que atende a sua necessidade:</td>

</tr>

<tr>

<td width="146" height="171" background="images/index_r3_c5.gif"><table width="100%" height="171" border="0" cellpadding="2" cellspacing="2">

<tr>

<td height="10"><img src="images/index_r10_c35.gif" alt="Krc Master" width="73" height="10"></td>

</tr>

<tr>

<td align="center" class="branco">Se você deseja investir pouco e precisa de um site que fique pronto rápido essa é a solução ideal.</td>

</tr>

<tr>

<td height="19" align="center" valign="middle"><a href="krc_slim.asp"><img src="images/index_r21_c14.gif" alt="Saiba Mais" width="81" height="19" border="0"></a></td>

</tr>

</table></td>

<td width="6" height="171"> </td>

<td width="146" height="171" background="images/index_r3_c5.gif"><table width="100%" height="171" border="0" cellpadding="2" cellspacing="2">

<tr>

<td height="10"><img src="images/index_r10_c24.gif" alt="Krc Master" width="116" height="12"></td>

</tr>

<tr>

<td align="center" class="branco">Um projeto sob medida que atenda objetivos específicos e que gere negócios. Isso é o que oferece o KRC premium!</td>

</tr>

<tr>

<td height="19" align="center" valign="middle"><a href="krc_premium.asp"><img src="images/index_r21_c14.gif" alt="Saiba Mais" width="81" height="19" border="0"></a></td>

</tr>

</table></td>

<td width="7" height="171"> </td>

<td width="146" height="171" background="images/index_r3_c5.gif"><table width="100%" height="171" border="0" cellpadding="2" cellspacing="2">

<tr>

<td height="10"><img src="images/index_r10_c11.gif" alt="Krc Master" width="102" height="10"></td>

</tr>

<tr>

<td align="center" class="branco">Gerenciamento de conteúdo e funcionalidades que devem ser utilizadas em área restrita. Seu projeto é o KRC master.</td>

</tr>

<tr>

<td height="19" align="center" valign="middle"><a href="krc_master.asp"><img src="images/index_r21_c14.gif" alt="Saiba Mais" width="81" height="19" border="0"></a></td>

</tr>

</table></td>

<td width="7" height="171"> </td>

<td width="146" height="171" background="images/index_r3_c5.gif"><table width="100%" height="171" border="0" cellpadding="2" cellspacing="2">

<tr>

<td height="10"><img src="images/index_r10_c30.gif" alt="Krc Master" width="136" height="10"></td>

</tr>

<tr>

<td align="center" class="branco">Que tal vender on-line? Aqui sua loja virtual fica pronta em 7 dias com layout personalizado! Não perca mais tempo.</td>

</tr>

<tr>

<td height="19" align="center" valign="middle"><a href="krc_commerce.asp"><img src="images/index_r21_c14.gif" alt="Saiba Mais" width="81" height="19" border="0"></a></td>

</tr>

</table></td>

</tr>

<tr>

<td height="6" colspan="7"></td>

</tr>

</table></td>

<td width="14" height="199" background="images/index_r12_c41.gif"> </td>

</tr>

</table></td>

</tr>

<tr>

<td height="100%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="422" height="100%" valign="top"><table width="100%" height="100%" border="0" cellpadding="3" cellspacing="3">

<tr>

<td width="50%" height="150" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td><img src="images/index_r23_c12.gif" alt="Clientes" width="100" height="26"></td>

</tr>

<tr>

<td align="center"><script language="javascript">flash2();</script></td>

</tr>

</table>

</td>

<td width="50%" height="150" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td><img src="images/index_r23_c26.gif" alt="Cadastre-se" width="136" height="26"></td>

</tr>

<tr>

<td height="130" align="center" valign="middle"><table width="100%" border="0" cellpadding="2" cellspacing="2" class="azul_marinho">

<form name="form2" method="post" action="">

<tr>

<td colspan="2">Receba novidades e promoções exclusivas: </td>

</tr>

<tr>

<td width="31%" align="right">Nome:</td>

<td width="69%"><input name="nome" type="text" class="borda" id="nome"></td>

</tr>

<tr>

<td align="right">E-mail:</td>

<td><input name="email" type="text" class="borda" id="email"></td>

</tr>

<tr>

<td colspan="2" align="center"><input type="image" name="imageField2" src="images/bt_enviar.jpg"></td>

</tr>

</form>

</table>

</td>

</tr>

</table> </td>

</tr>

<tr>

<td height="26" colspan="2" valign="top"><img src="images/index_r28_c12.gif" alt="Conheça Mais" width="150" height="26"></td>

</tr>

<tr>

<td height="154" colspan="2" valign="top"><!--#include file="exibe_noti.asp"--></td>

</tr>

</table></td>

<td width="196" height="365"><!--#include file="depo_detalhe.asp" --></td>

</tr>

</table></td>

</tr>

<tr>

<td height="15"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="527" background="images/index_r35_c4a.gif"></td>

<td width="97"><img src="images/index_r33_c36a.gif" width="97" height="15"></td>

</tr>

</table></td>

</tr>

</table></td>

<td width="122" height="100%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="123" valign="bottom" background="images/index_r11_c2.gif"><img src="images/index_r17_c42.gif" width="122" height="11"></td>

</tr>

<tr>

<td height="205" valign="top"><!--#include file="atendimento.asp" --></td>

</tr>

<tr>

<td height="100%" valign="bottom" background="images/index_r27_c42.gif"><img src="images/index_r30_c42.gif" width="122" height="81"></td>

</tr>

<tr>

<td height="39" background="images/index_r3_c5.gif"><img src="images/index_r34_c42.gif" width="8" height="39"></td>

</tr>

</table></td>

</tr>

</table></td>

<td height="100%" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="123" valign="bottom" background="images/index_r11_c2.gif"> </td>

</tr>

<tr>

<td height="3"></td>

</tr>

<tr>

<td height="100%" background="images/index_fundo.jpg"> </td>

</tr>

<tr>

<td height="39" background="images/index_r3_c5.gif"> </td>

</tr>

</table></td>

</tr>

 

<tr>

<td height="86" background="images/index_r3_c5.gif"> </td>

<td height="86" background="images/index_r3_c5.gif"><!--#include file="rodape.asp" --></td>

<td height="86" background="images/index_r3_c5.gif"> </td>

</tr>

<tr>

<td height="133" background="images/index_r19_c2.gif"> </td>

<td width="779" height="133"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="345" background="images/index_r19_c2.gif"><!--#include file="creditos.asp" --></td>

<td width="3"> </td>

<td width="431" align="center" valign="middle" background="images/index_r43_c30.gif"><!--#include file="antispam.asp" --></td>

</tr>

</table></td>

<td height="133" background="images/index_r43_c30.gif"> </td>

</tr>

</table>

</body>

</html>

Include 1

depo_detalhe.asp

CODE
<!--#Include File="adm/conexao.asp"-->

<%

Dim Vid

 

Vid = Request.QueryString("id")

 

Call AbreConn()

 

sql = "Select * From tbdepo Where indepo=" & 2

 

Set rs = conn.Execute(sql)

 

'Setando a variável foto para receber o nome da imagem do banco de dados

foto = Rs("imagem")

 

%>

 

<link href="inc/estilos.css" rel="stylesheet" type="text/css">

<style type="text/css">

<!--

body {

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

}

-->

</style><table width="195" height="365" border="0" cellpadding="0" cellspacing="0">

<tr>

<td valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="182" height="100%" background="images/index_r19_c2.gif"><table width="100%" height="100%" border="0" cellpadding="2" cellspacing="2">

<tr>

<td height="20"><img src="images/index_r24_c33.gif" alt="Depoimentos" width="116" height="12"></td>

</tr>

<tr>

<td height="235" valign="middle" class="azul_marinho"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="azul_marinho"><p><%Response.Write(Replace(rs("depoimento"), Chr(13) & Chr(10), "<br />"))%></p> </td>

</tr>

<tr>

<td class="azul_marinho"> </td>

</tr>

<tr>

<td height="15" class="azul_marinho"><strong><%=rs("nome")%></strong></td>

</tr>

<tr>

<td height="15" class="azul_marinho">Corporate Relations </td>

</tr>

<tr>

<td height="15" class="azul_marinho"><%=rs("empresa")%></td>

</tr>

</table> </td>

</tr>

</table></td>

<td width="14" height="100%" background="images/index_r12_c41.gif"> </td>

</tr>

<tr>

<td height="105" colspan="2" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="99" height="105" rowspan="3" background="images/index_r19_c2.gif"><table width="100%" height="105" border="0" cellpadding="2" cellspacing="2" class="azul_marinho">

<tr>

<td align="right" valign="bottom">< 2 de 10 > </td>

</tr>

</table></td>

<td width="97"><img src="images/index_r30_c36.gif" width="97" height="23"></td>

</tr>

<tr>

<td height="46"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="23"><img src="images/index_r32_c36.gif" width="23" height="46"></td>

<td width="73" height="46" align="center" valign="middle"><img src="images/logo_scania_peq.gif" alt="Scania" width="73" height="42"></td>

</tr>

</table></td>

</tr>

<tr>

<td width="97"><img src="images/index_r33_c36.gif" width="97" height="36"></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

</table>

 

<%

rs.Close()

Set rs = Nothing

 

Call FechaConn()

%>

Include 2

artigos_detalhe.asp

CODE
<!--#Include File="adm/conexao.asp"-->

<%

Dim Vid

 

Vid = Request.QueryString("id")

 

Call AbreConn()

 

sql = "Select * From tbNoticia Where inNoticia=" & Vid

 

Set rs = conn.Execute(sql)

 

'Setando a variável foto para receber o nome da imagem do banco de dados

foto = Rs("imagem")

 

%>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> KRC Design - Criação de web sites, Design Digital e Design Gráfico </title>

<META NAME="Description" CONTENT="Empresa localizada em Santo André - SP, especializada em arquitetura e construções" />

<META NAME="Keywords" CONTENT="arquitetura construções design de interiores projetos casas prédios lojas buffets" />

<META NAME="Language" CONTENT="Portuguese" />

<META NAME="Author" CONTENT="KRC Design - www.krcdesign.com.br" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta name="robots" content="index,follow" />

<link href="inc/estilos.css" rel="stylesheet" type="text/css">

<script src="inc/flash1.js" type="text/javascript"></script>

<script src="inc/flash2.js" type="text/javascript"></script>

</head>

 

<body>

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="29" background="images/index_r3_c5.gif" class="login"> </td>

<td height="29" background="images/index_r3_c5.gif" class="login"><!--#include file="restrito.asp" --></td>

<td height="29" background="images/index_r3_c5.gif" class="login"> </td>

</tr>

<tr>

<td height="279" align="right" valign="top" background="images/fdo_topo_risco.jpg" class="login"> </td>

<td height="279" class="login"><script language="javascript">flash1();</script></td>

<td height="279" background="images/fdo_topo_risco.jpg" class="login"> </td>

</tr>

<tr>

<td height="100%" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="123" background="images/index_r11_c2.gif"> </td>

</tr>

<tr>

<td height="3"></td>

</tr>

<tr>

<td height="100%" background="images/index_r19_c2.gif"> </td>

</tr>

<tr>

<td height="39" background="images/index_r3_c5.gif"> </td>

</tr>

</table></td>

<td height="100%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="25" height="100%" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="123" background="images/index_r11_c2.gif"> </td>

</tr>

<tr>

<td height="3"></td>

</tr>

<tr>

<td height="100%" background="images/index_r19_c2.gif"> </td>

</tr>

<tr>

<td height="39" background="images/index_r3_c5.gif"> </td>

</tr>

</table></td>

<td width="14" height="100%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="100%" background="images/index_r11_c4.gif"> </td>

</tr>

<tr>

<td height="15"><img src="images/index_r35_c4.gif" width="14" height="15"></td>

</tr>

</table></td>

<td width="618" height="100%" align="left" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

 

<tr>

<td height="100%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="604" height="100%" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="240" height="33"><img src="images/tarja_artigos.gif" alt="KRC Design" width="240" height="33"></td>

<td height="33"> </td>

</tr>

<tr>

<td height="100%" colspan="2"><table width="100%" border="0" cellpadding="2" cellspacing="2" class="cinza">

<tr>

<td width="20"> </td>

<td colspan="2" class="titu_la"><%=rs("titulo")%></td>

</tr>

<tr>

<td width="20"> </td>

<td colspan="2" class="azul_marinho"><%=rs("chNoticia")%></td>

</tr>

<tr>

<td width="20"> </td>

<td colspan="2" class="assina"><%=rs("dtNoticia")%></td>

</tr>

<tr>

<td width="20"> </td>

<td colspan="2"><img src="../fotos<%=foto%>"></td>

</tr>

<tr>

<td width="20"> </td>

<td colspan="2" rowspan="2"><div align="justify">

<%

Response.Write(Replace(rs("vcNoticia"), Chr(13) & Chr(10), "<br />"))

 

rs.Close()

Set rs = Nothing

 

Call FechaConn()

%>

</div></td>

</tr>

<tr>

<td width="20"> </td>

</tr>

<tr>

<td> </td>

<td colspan="2"><hr>

<p class="titu_la"><a href="Indique.asp">Indique esse artigo:</a></p>

<p> </p></td>

</tr>

 

</table>

</td>

</tr>

</table></td>

<td width="14" height="100%" background="images/index_r12_c41.gif"><p> </p>

<p> </p>

<p> </p>

<p> </p>

<p> </p></td>

</tr>

<tr>

<td width="604" height="20" align="right"><a href="java script:history.back()"><img src="images/bt_voltar.jpg" alt="Voltar" width="73" height="18" border="0"></a></td>

<td width="14" height="20" background="images/index_r12_c41.gif"> </td>

</tr>

</table></td>

</tr>

<tr>

<td height="15"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="527" background="images/index_r35_c4a.gif"></td>

<td width="97"><img src="images/index_r33_c36b.gif" width="97" height="15"></td>

</tr>

</table></td>

</tr>

</table></td>

<td width="122" height="100%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="123" valign="bottom" background="images/index_r11_c2.gif"><img src="images/index_r17_c42.gif" width="122" height="11"></td>

</tr>

<tr>

<td height="205" valign="top"><!--#include file="atendimento.asp" --></td>

</tr>

<tr>

<td height="100%" valign="bottom" background="images/index_r27_c42.gif"> </td>

</tr>

<tr>

<td height="39" background="images/index_r3_c5.gif"> </td>

</tr>

</table></td>

</tr>

</table></td>

<td height="100%" valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="123" valign="bottom" background="images/index_r11_c2.gif"> </td>

</tr>

<tr>

<td height="3"></td>

</tr>

<tr>

<td height="100%" background="images/index_fundo.jpg"> </td>

</tr>

<tr>

<td height="39" background="images/index_r3_c5.gif"> </td>

</tr>

</table></td>

</tr>

 

<tr>

<td height="86" background="images/index_r3_c5.gif"> </td>

<td height="86" background="images/index_r3_c5.gif"><!--#include file="rodape.asp" --></td>

<td height="86" background="images/index_r3_c5.gif"> </td>

</tr>

<tr>

<td height="133" background="images/index_r19_c2.gif"> </td>

<td width="779" height="133"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="345" background="images/index_r19_c2.gif"><!--#include file="creditos.asp" --></td>

<td width="3"> </td>

<td width="431" align="center" valign="middle" background="images/index_r43_c30.gif"><!--#include file="antispam.asp" --></td>

</tr>

</table></td>

<td height="133" background="images/index_r43_c30.gif"> </td>

</tr>

</table>

</body>

</html>

 

Valeu galera

Share this post


Link to post
Share on other sites

Então cara isso é pq tem mais de uma conexão tente tirar uma conexão de um include !!!!

Share this post


Link to post
Share on other sites

dim conn

 

Você não pode declarar a mesma variável duas vezes.

 

Lembre-se que se você declara em um arquivo e chama por include, você vai declarar o mesmo número de vezes que esse arquivo for chamado.

 

Uma solução, seria você chamar o conexao.asp no inicio do index.asp e remove o include das outras páginas que index.asp chama.

Share this post


Link to post
Share on other sites

Eu fiz isso cara,

 

tirei o <!--#Include File="adm/conexao.asp"-->

das duas páginas e deixei na index.asp

 

Continua dando o mesmo erro.

Share this post


Link to post
Share on other sites

Ok, então dá uma verificada na sua página e tbm nos includes, pois só pode haver uma conexão ... dim cnn só pode se declarad uma vez

Share this post


Link to post
Share on other sites

Galera tá resolvido,

o problema era o seguinte,

 

Eu estava usando os includes exibe_noticias.asp e depo_detalhe.asp e não artigos_detalhe.asp e depo_detalhe.asp.

 

Ao invés tirar o arquivo que chama a conexão da página artigos_detalhe.asp e tinha que alterar da página exibe_noticias.asp....hehehe....pura falta de atenção...

 

Graças aos comentários do pessoal eu consegui entender o que estava acontecendo e me atentar ao nome correto dos includes...

 

valeu mesmo galera.....

 

grande abraço à todos...

Share this post


Link to post
Share on other sites

Quem bom q resolveu, a falta de atenção acontece muito principalmente comigo hehehehe, e isso gera um tipo de erro assim, mas é isso ai

Share this post


Link to post
Share on other sites

×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.