Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Bateraman

[Resolvido] Problema no Dim MM_editCmd

Recommended Posts

Olá.

Fazendo-se o processo separado eu consigo insertar no banco de dados.

Tenho 2 formulários na mesma página.

 

Aliás, tinha um: o de newsletter - que inseria no banco de dados o nome e email da pessoa. Beleza funfava normal.

 

Inseri também agora, um outro formulário : Formindica, que serve para o cara indicar o site para outra pessoa.

 

O problema é que a página não carrega mais, e fica dando esse erro:

 

 

 

ERRO:

Informações técnicas (para a equipe de suporte)

 

Tipo de erro:

Erro de compilação do Microsoft VBScript (0x800A0411)

Redefinição do nome

/lasercorte/indique-este-site.asp, line 67, column 4

Dim MM_editCmd

---^

 

 

Tá, como eu sei que vão me perguntar o que tem na linha 67

 

<%
If (CStr(Request("MM_insert")) = "formindica") Then
  If (Not MM_abortEdit) Then
	' execute the insert
	Dim MM_editCmd	<---------------------LINHA 67

	Set MM_editCmd = Server.CreateObject ("ADODB.Command")
	MM_editCmd.ActiveConnection = MM_Conexao_STRING
	MM_editCmd.CommandText = "INSERT INTO indique (nome, email, nomedestinatario, emaildestinatario, mensagemdestinatario) VALUES (?, ?, ?, ?, ?)" 
	MM_editCmd.Prepared = true
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("nome")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("email")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("nomedestinatario")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("emaildestinatario")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("mensagemdestinatario")) ' adVarWChar
	MM_editCmd.Execute
	MM_editCmd.ActiveConnection.Close

	' append the query string to the redirect URL
	Dim MM_editRedirectUrl
	MM_editRedirectUrl = "redirect.asp"
	If (Request.QueryString <> "") Then
	  If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
		MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
	  Else
		MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
	  End If
	End If
	Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>

Muito obrigado pela atenção!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá Bateraman...

 

como disse o fernando, corretamente, basta apagar a linha q tah com o código: Dim MM_editCmd.

 

mas pq?!

 

pq você não pode declarar 2 ou mais vezes a mesma variável.

 

se você procurar em seu código, a mesma já deve ter sido declara anteriormente....

 

abraços...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Então,

Tentei apagar lá e não deu.

Vou postar o código. Sao 2 formulários.

 

Eu não entendo pq não dá.

 

 

 

<!-- InstanceBegin template="/Templates/aaaaadwt.asp" codeOutsideHTMLIsLocked="false" --><%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/aa.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_insert")) = "formnews") Then   obs:---------------------------<<<<<<<<<<<<<<<<<formnews é o  FORMULÁRIO DE NEWSLETTER |||||||||||||||||||||||||||||||||||||||||||||||| 
  If (Not MM_abortEdit) Then
	' execute the insert
	Dim MM_editCmd

	Set MM_editCmd = Server.CreateObject ("ADODB.Command")
	MM_editCmd.ActiveConnection = MM_Ert_STRING
	MM_editCmd.CommandText = "INSERT INTO news (nome, email, empresa, Cidade, Estado) VALUES (?, ?, ?, ?, ?)" 
	MM_editCmd.Prepared = true
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("nome")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("email")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("empresa")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("cidade")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("estado")) ' adVarWChar
	MM_editCmd.Execute
	MM_editCmd.ActiveConnection.Close

	' append the query string to the redirect URL
	Dim MM_editRedirectUrl
	MM_editRedirectUrl = "b.asp"
	If (Request.QueryString <> "") Then
	  If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
		MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
	  Else
		MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
	  End If
	End If
	Response.Redirect(MM_editRedirectUrl)
  End If
End If
%><head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<%
If (CStr(Request("MM_insert")) = "formIndica") Then obs:---------------------------<<<<<<<<<<<<<<<<< FORMULÁRIO DE INDICAÇÃO DO SITE|||||||||||||||||||||||||||||||||||||||||||||||| 
  If (Not MM_abortEdit) Then
	' execute the insert
	Dim MM_editCmd

	Set MM_editCmd = Server.CreateObject ("ADODB.Command")
	MM_editCmd.ActiveConnection = MM_Ert_STRING
	MM_editCmd.CommandText = "INSERT INTO indique (nomeindica, emailindica) VALUES (?, ?)" 
	MM_editCmd.Prepared = true
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("nomeindica")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("emailindica")) ' adVarWChar
	MM_editCmd.Execute
	MM_editCmd.ActiveConnection.Close

	' append the query string to the redirect URL
	Dim MM_editRedirectUrl
	MM_editRedirectUrl = "adm.asp"
	If (Request.QueryString <> "") Then
	  If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
		MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
	  Else
		MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
	  End If
	End If
	Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>
<title>teste</title>
<!-- InstanceEndEditable -->
<html> etc....

Obrigado!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pessoal,

 

para redimir minha ignorância.

 

Consegui resolver o problema. Simplifiquei o código deste jeito:

 

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/Ert.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false

Dim MM_abortEdit2
MM_abortEdit2 = false
%>




<%
If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
	' execute the insert
	Dim MM_editCmd

	Set MM_editCmd = Server.CreateObject ("ADODB.Command")
	MM_editCmd.ActiveConnection = MM_Ert_STRING
	MM_editCmd.CommandText = "INSERT INTO news (nome, email) VALUES (?, ?)" 
	MM_editCmd.Prepared = true
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, -1, Request.Form("nome")) ' adVarWChar
	MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, -1, Request.Form("email")) ' adVarWChar
	MM_editCmd.Execute
	MM_editCmd.ActiveConnection.Close

	' append the query string to the redirect URL
	Dim MM_editRedirectUrl
	MM_editRedirectUrl = "boss.asp"
	If (Request.QueryString <> "") Then
	  If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
		MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
	  Else
		MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
	  End If
	End If
	Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>







<%
If (CStr(Request("MM_insert")) = "form2") Then
  If (Not MM_abortEdit2) Then
	' execute the insert
	Dim MM_editCmd2

	Set MM_editCmd2 = Server.CreateObject ("ADODB.Command")
	MM_editCmd2.ActiveConnection = MM_Ert_STRING
	MM_editCmd2.CommandText = "INSERT INTO indique (nomeindica, emailindica, nomedestinatario, emaildestinatario) VALUES (?, ?, ?, ?)" 
	MM_editCmd2.Prepared = true
	MM_editCmd2.Parameters.Append MM_editCmd2.CreateParameter("param1", 202, 1, -1, Request.Form("nomeindica")) ' adVarWChar
	MM_editCmd2.Parameters.Append MM_editCmd2.CreateParameter("param2", 202, 1, -1, Request.Form("emailindica")) ' adVarWChar
	MM_editCmd2.Parameters.Append MM_editCmd2.CreateParameter("param3", 202, 1, -1, Request.Form("nomedestinatario")) ' adVarWChar
	MM_editCmd2.Parameters.Append MM_editCmd2.CreateParameter("param4", 202, 1, -1, Request.Form("emaildestinatario")) ' adVarWChar
	MM_editCmd2.Execute
	MM_editCmd2.ActiveConnection.Close

	' append the query string to the redirect URL
	Dim MM_editRedirectUrl2
	MM_editRedirectUrl2 = "boss.asp"
	If (Request.QueryString <> "") Then
	  If (InStr(1, MM_editRedirectUrl2, "?", vbTextCompare) = 0) Then
		MM_editRedirectUrl2 = MM_editRedirectUrl2 & "?" & Request.QueryString
	  Else
		MM_editRedirectUrl2 = MM_editRedirectUrl2 & "&" & Request.QueryString
	  End If
	End If
	Response.Redirect(MM_editRedirectUrl2)
  End If
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
  <label>
  nome
  <input type="text" name="nome" id="nome" />
  </label>
  <p>
	<label>email
	<input type="text" name="email" id="email" />
	</label>
  </p>
  <p>
	<label>
	<input type="submit" name="btenvia1" id="btenvia1" value="Submit" />
	</label>
  </p>

	<input type="hidden" name="MM_insert" value="form1" />
</form>

<p> </p>
<form id="form2" name="form2" method="POST" action="<%=MM_editAction%>">
  <label>Nome Indica
  <input type="text" name="nomeindica" id="nomeindica" />
  </label>
  <p>
	<label>Email Indica
	<input type="text" name="emailindica" id="emailindica" />
	</label>
  </p>
  <p>
	<label>Nome Destinatario
	<input type="text" name="nomedestinatario" id="nomedestinatario" />
	</label>
  </p>
  <p>
	<label>Email Destinatario
	<input type="text" name="emaildestinatario" id="emaildestinatario" />
	</label>
  </p>
  <p>
	<label>
	<input type="submit" name="submit" id="submit" value="Submit" />
	</label>
  </p>

  <input type="hidden" name="MM_insert" value="form2" />
</form>
<p> </p>
</body>
</html>

 

Obrigado Otton e Fernando!! http://forum.imasters.com.br/public/style_emoticons/default/natal_biggrin.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.