Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
É o seguinte:
Peguei esse código na net e o mesmo faz o cadastro (funcionando perfeitamento) e deleta o registro (dando pau). Fiz algumas modificações para trabalhar em access, mas quando tento excluir um registro ele não vai.
Seguem os códigos:
ajaxCarregar.js
function GetXMLHttp() {
var xmlHttp;
try {
xmlHttp = new XMLHttpRequest();
}
catch(ee) {
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
xmlHttp = false;
}
}
}
return xmlHttp;
}
var Enviar = GetXMLHttp();
// Início - Cadastro
function CadastrarDados() {
var Nome = document.getElementById("Nome");
var EMail = document.getElementById("EMail");
var URL = "Cadastro.asp?Cadastrar=Ok&Nome="+Nome.value+"&EMail="+EMail.value+"";
Enviar.open("GET", URL, true);
Enviar.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.getElementById("Resposta").innerHTML = "Cadastrado com Sucesso!!!";
Nome.value = "";
EMail.value = "";
Enviar.send(null);
Enviar.onload = lerTexto;
}// Início - Deletar
function apagar(id, rowIndex) {
if (confirm('Tem certeza que deseja excluir este registro?')) {
document.getElementById("tabela").deleteRow(rowIndex);
Enviar.open("GET",'Cadastro.asp?Deletar=Ok&id='+id,false);
Enviar.send(null);
}
}// Início - Carregar Página
function lerTexto() {
var URLler = "Ler.asp";
Enviar.onreadystatechange = stateChanged;
Enviar.open("GET", URLler, true);
Enviar.send(null);
}
function stateChanged() {
if (Enviar.readyState==4) {
document.getElementById("ler_Dados").innerHTML = Enviar.responseText;
}
}
window.onload = lerTexto;ler.asp
<!--#include file="bib_conexao.asp"-->
<%
Dim Conexao, rs, sqldel, id
sqldel = "select * from teste"
Call abre_conexao
Set rs = Conexao.Execute(sqldel)
%>
<table width="407" border="1" cellspacing="0" cellpadding="0" id="tabela">
<tr>
<td width="164"><strong>NOME</strong></td>
<td width="159"><strong>EMAIL</strong></td>
<td width="76"><strong>Acionar</strong></td>
</tr><tr>
<td><%=rs("Nome")%></td>
<td><%=rs("EMail")%></td>
<td><a href="#" onClick="apagar('<%=rs("codigo")%>', this.parentNode.parentNode.rowIndex);">deletar</a></td>
</tr>cadastro.asp
<!--#include file="bib_conexao.asp"-->
<%
Dim Conexao, rsca, sqlca, id
sqlca = "select * from teste"
Call abre_conexao
Set rs = Conexao.Execute(sqlca)
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cadastrar</title>
<script language="javascript" src="ajaxCarregar.js"></script>
</head>
<body>
<div id="Resposta"></div><br>
<form id="Form">
Nome: <input type="text" id="Nome" name="Nome" value=""><br>
E-Mail: <input type="text" id="EMail" name="EMail" value=""><br>
<input type="button" id="Cadastrar" value="Cadastrar" name="Cadastrar" onClick="CadastrarDados();">
</form><br>
<br>
<br>
<div id="ler_Dados"></div>
</body>
</html>if (Request.QueryString("Deletar") = "Ok") then
Conexao.Execute("Delete From Teste Where Codigo = '"+Request.QueryString("id")+"'")
Response.Write("")
End If
%>
==========================================================================================================
Alguém pode me ajudar a resolver esse problema?
Grato,
Alexandro.
Carregando comentários...