Ir para conteúdo

POWERED BY:

Arquivado

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

Marcello-Master

Exclama o erro mas grava o registro ?!?!?

Recommended Posts

Ola Galera,

Estou com o seguinte problema, eu Cadastro um registro mas coloquei algumas validações no mesmo e o que esta acontecendo é que ela aparece o que está faltando preencher determinados campos, mas ele grava assim mesmo.... sendo que não deveria gravar a não ser que tivesse todos os campos obrigatorios preenchidos...

 

 

O que eu fiz de errado na validação ????

 

 

Esse é o codigo....

<!-- #include file = "upload_funcoes.asp" --><%' Chamando Funções, que fazem o Upload funcionarbyteCount = Request.TotalBytesRequestBin = Request.BinaryRead(byteCount)Set UploadRequest = CreateObject("Scripting.Dictionary")BuildUploadRequest RequestBin' Recuperando os Dados Digitados ----------------------tp_imovel 		= UploadRequest.Item("tp_imovel").Item("Value")desc_lancamento = UploadRequest.Item("desc_lancamento").Item("Value")nivel_prioridade= UploadRequest.Item("nivel_prioridade").Item("Value")desc_aluguel	= UploadRequest.Item("desc_aluguel").Item("Value")ativo			= UploadRequest.Item("ativo").Item("Value")desc_simples	= UploadRequest.Item("desc_simples").Item("Value")valor			= UploadRequest.Item("valor").Item("Value")referencia		= UploadRequest.Item("referencia").Item("Value")desc_negrito01	= UploadRequest.Item("desc_negrito01").Item("Value")desc_negrito02	= UploadRequest.Item("desc_negrito02").Item("Value")desc_imovel		= UploadRequest.Item("desc_imovel").Item("Value")endereco		= UploadRequest.Item("endereco").Item("Value")bairro			= UploadRequest.Item("bairro").Item("Value")corretor		= UploadRequest.Item("corretor").Item("Value")sData = Datehora = Time%><style type="text/css"><!--.texto8 {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: normal; color: #333333; text-decoration: none}.texto8bold {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: bold; color: #3F68AD; text-decoration: none}.texto7 {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; font-weight: normal; color: #000000; text-decoration: none}.texto8boldred { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: bold; color: #FF0000; text-decoration: none }.sombra {		filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=3, OffY=5, Color='#999999', Positive='true')		}.texto8boldblac {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: bold; color: #3F68AD; text-decoration: none}.style1 {	font-size: 18px;	font-family: arial;	color: #3F68AD;}.style3 {font-size: 7pt}--></style><body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0"><table width="774" border="0" cellspacing="0" cellpadding="0">  <tr>	<td><img src="../imagens/topo.gif" alt="z" width="774" height="150" border="0" usemap="#MapMap" />		<map name="MapMap" id="MapMap">		  <area shape="rect" coords="160,111,241,130" href="seg_pag_asp/home.html" target="2" />		</map>	</td>  </tr></table><table width="774" border="0" cellspacing="0" cellpadding="0">  <tr class="texto8">	<td height="13"><table width="100%" border="0" cellspacing="0" cellpadding="0">	  <tr>		<td width="77%" height="21"><span class="style3"> 				<script language="JavaScript" type="text/javascript" class="texto8">		hoje = new Date()		dia = hoje.getDate()		dias = hoje.getDay()		mes = hoje.getMonth()		ano = hoje.getYear()		if (dia < 10)				dia = "0" + dia		if (ano < 2000)				ano = "19" + ano		function CriaArray (n) {		this.length = n }		NomeDia = new CriaArray(7)			NomeDia[0] = "Domingo"			NomeDia[1] = "Segunda"			NomeDia[2] = "Terça"			NomeDia[3] = "Quarta"			NomeDia[4] = "Quinta"			NomeDia[5] = "Sexta"			NomeDia[6] = "Sábado"		 NomeMes = new CriaArray(12)			NomeMes[0] = "Janeiro"			NomeMes[1] = "Fevereiro"			NomeMes[2] = "Março"			NomeMes[3] = "Abril"			NomeMes[4] = "Maio"			NomeMes[5] = "Junho"			NomeMes[6] = "Julho"			NomeMes[7] = "Agosto"			NomeMes[8] = "Setembro"			NomeMes[9] = "Outubro"			NomeMes[10] = "Novembro"			NomeMes[11] = "Dezembro"function escreveData(){ if (ano == '19100') ano = '2000'; document.write (NomeDia[dias] + ", " + dia + " de " + NomeMes[mes] + " de " + ano)}			  </script>				<script language="JavaScript" type="text/javascript">escreveData()			  </script>		  – Moradia Imobiliária – Tel.: (11) 6546.2299 – Fax: (11) 6943.2121 </span></td>		<td width="12%"><li ><a href="javascript:history.go(-1)" class="texto8bold">« Voltar</a><a href="../admin.asp" class="texto8bold"></a></td>		<td width="11%"><div align="center">		  <li><a href="../login_skip.asp" class="texto8bold">Sair</a></li>		</div></td>	  </tr>	  <tr>		<td height="2" colspan="3"><hr size="1" color="#CCCCCC"></td>	  </tr>	</table></td>  </tr></table><table width="774" border="0" cellspacing="0" cellpadding="0" height="57">  <tr>	<td height="57" valign="top"><br>	<table width="597" border="0" align="center" cellpadding="0" cellspacing="0">	  <tr>		<td width="597" class="texto8"><table width="100%" border="0" cellspacing="0" cellpadding="0">		  <tr>			<td width="16%"> </td>			<td width="84%" class="texto8"><%if tp_imovel = "" then	   response.Write("<li>O Campo <b>Tipo de Imóvel</b> está em branco !!!...<br><br>")end ifif desc_lancamento = "" then	   response.Write("<li>O Campo <b>Lançamento</b> está em branco !!!...<br><br>")end ifif desc_aluguel = "" then	   response.Write("<li>O Campo <b>Venda / Aluguel</b> está em branco !!!...<br><br>")end ifif nivel_prioridade = "" then	   response.Write("<li>O Campo <b>Prioridade</b> está em branco !!!...<br><br>")end ifif ativo = "" then	   response.Write("<li>O Campo <b>Ativo</b> está em branco !!!...<br><br>")end ifif desc_simples = "" then	   response.Write("<li>O Campo <b>Descrição Simples do Imóvel</b> está em branco !!!...<br><br>")end ifif valor = "" then	   response.Write("<li>O Campo <b>Valor</b>  está em branco !!!...<br><br>")end ifif referencia = "" then	   response.Write("<li>O Campo <b>Referência</b> está em branco !!!...<br><br>")end ifif desc_negrito02 = "" then	   response.Write("<li>O Campo <b>Titulo Negrito</b> está em branco !!!...<br><br>")end ifif desc_imovel = "" then	   response.Write("<li>O Campo <b>Descrição do Imóvel</b> está em branco !!!...<br><br>")end ifif endereco = "" then	   response.Write("<li>O Campo <b>Endereço</b> está em branco !!!...<br><br>")end ifif bairro = "" then	   response.Write("<li>O Campo <b>Bairro</b> está em branco !!!...<br><br>")else' Tipo de arquivo que esta sendo enviadotipo_imagem02 = UploadRequest.Item("imagem02").Item("ContentType")' Caminho completo dos arquivos enviadoscaminho_imagem02 = UploadRequest.Item("imagem02").Item("FileName")' Nome dos arquivos enviadosnome_imagem02 = Right(caminho_imagem02,Len(caminho_imagem02)-InstrRev(caminho_imagem02,"\"))' Conteudo binario dos arquivos enviadosimagem02 = UploadRequest.Item("imagem02").Item("Value")' pasta onde as fotos serao guardadaspasta = Server.MapPath("..\fotos\")nome_imagem02 = "\"&nome_imagem02' pasta + nome dos arquivoscimagem02 = "..\fotos" + nome_imagem02	   	' Fazendo o Upload do arquivo selecionadoif cimagem02="..\fotos\" then   cimagem02="..\fotos\sem-foto.jpg"end ifif imagem02 <> "" thenSet ScriptObject = Server.CreateObject("Scripting.FileSystemObject")Set MyFile = ScriptObject.CreateTextFile(pasta & nome_imagem02)For i = 1 to LenB(imagem02)MyFile.Write chr(AscB(MidB(imagem02,i,1)))NextMyFile.Closeend if' Conecta-se ao Banco de Dadosurl_conexao = Server.MapPath("..\bd\bd.mdb")set conexao = Server.CreateObject("ADODB.Connection")conexao.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&url_conexao 	if ativo="Não" then		ativo="0"	end if	if ativo="Sim" then		ativo="1"	end if' cadastra os dados no banco de dadossql = "Insert into imovel(tp_imovel,desc_lancamento,desc_aluguel,nivel_prioridade,ativo,imagem02,desc_simples,valor,referencia,desc_negrito01,desc_negrito02,desc_imovel,endereco,bairro,corretor,data,hora) values('"&tp_imovel&"','"&desc_lancamento&"','"&desc_aluguel&"','"&nivel_prioridade&"','"&ativo&"','"&cimagem02&"','"&desc_simples&"','"&valor&"','"&referencia&"','"&desc_negrito01&"','"&desc_negrito02&"','"&desc_imovel&"','"&endereco&"','"&bairro&"','"&corretor&"','"&sData&"','"&hora&"')"Conexao.Execute(sql)%></td>		  </tr>		</table></td>		</tr>	  <tr>		<td height="19" valign="top" class="texto8bold"><table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">		  <tr>			<td>			  <div align="center" class="texto8bold">				<%' Mostra Mensagem de Confirmação na TelaResponse.write "Dados Cadastrados com Sucesso!"' Redireciona após 5 segundos'response.write "<br><br>você será redirecionado em 5 segundos..<br>"'response.write "<meta http-equiv='refresh' content='2; url=../admin.asp'/>"end if%>							</div></td>			  </tr>		  </table>			<div align="center"><br />			</div></td>		</tr>	  <tr>		<td valign="top" height="10"> </td>		</tr>	</table></td></tr></table><table width="774" border="0" cellspacing="0" cellpadding="0">  <tr class="texto8">	<td><hr size="1" />	</td>  </tr>  <tr class="texto8">	<td><div align="center">MORADIA 	  IMOBILIÁRIA – <a href="mailto:contato@moradia.imb.br" class="texto8">contato@moradia.imb.br</a> – Tel.: (11) 6546.2299 – Fax: (11) 6943-2121</div></td>  </tr></table></body>

Fico grato pela Ajuda

 

Valew Galera http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

Camarada,

 

 

Bem onde você efetua a consistência:

if tp_imovel = "" thenresponse.Write("<li>O Campo <b>Tipo de Imóvel</b> está em branco !!!...<br><br>")end if

você pode redirecionar para outra página:

if tp_imovel = "" thenresponse.Write("<li>O Campo <b>Tipo de Imóvel</b> está em branco !!!...<br><br>")response.redirect "sua_pagina_qdo_dados_incosistentes"response.endend if

Ou cria um flag:

''Antes dos IF´sdados_ok = trueif tp_imovel = "" thenresponse.Write("<li>O Campo <b>Tipo de Imóvel</b> está em branco !!!...<br><br>")dados_ok = falseend if

E onde é feita a gravação faça o teste asim:

If dados_ok then	' cadastra os dados no banco de dados	sql = "Insert into imovel(tp_imovel,desc_lancamento,desc_aluguel,nivel_prioridade,ativo,imagem02,de	sc_simples,valor,referencia,desc_negrito01,desc_negrito02,desc_imovel,endereco,b	airro,corretor,data,hora) values('"&tp_imovel&"','"&desc_lancamento&"','"&desc_aluguel&"','"&nivel_prioridade&"','"&ativo&"','"&cimagem02&"','"&desc_simples&"','"&valor&"','"&referencia&"','"&desc_negrito01&"','"&desc_negrito02&"','"&desc_imovel&"','"&endereco&"','"&bairro&"','"&corretor&"','"&sData&"','"&hora&"')"	Conexao.Execute(sql)End if

Bom são elocubraçoes e dicas cabe a tu que conheces o ambiente e suas peculiaridades decidir qual a melho forma.

 

Eu aconselho o REDIRECT.

 

Na dúdiva manifeste.

 

t+

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.