Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Alguém pode ver se tem algum erro aparente?
<%p_date=request("p_data")p_edit=("editar")......if p_date<>"" or p_edit<>"" thenif p_date="" then p_date=cdate("01/01/70") end if set bd_engespro = server.createObject("ADODB.Connection") bd_engespro.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../supervisao/database/superv_engespro.mdb") & ";" set diario = Server.CreateObject("ADODB.RecordSet") diario.Open "select * from Diario_obra where cod_obra='"&p_cod_obra&"'order by data_ocorrencia", bd_engespro,adOpenDynamic do while not diario.EOF if diario("Codigo")=p_edit or diario("data_ocorrencia")=p_data then%>Já existe Ocorrência nesta Data!<table WIDTH="80%" ALIGN="center" BORDER="1" CELLSPACING="0" CELLPADDING="0"> <tr> <td> <P align=center>Data</P></td> <td> <P align=center>Página do Diário</P></td> <td> <P align=center>Ocorrência</P></td> </tr> <tr> <td><%= diario("data_ocorrencia")%></td> <td><P align=center><%= diario("pag_l_obras")%></td> <%ocorrencia=diario("ocorrencias")%> <td><%= replace(ocorrencia,chr(13),"<br>")%></td> </tr></table> <br><font color="red">EDITAR</font><br><% p_existente = p_data exit do end if if diario.EOF then Response.Write "Não existe nenhuma Ocorrência nesta Data!<BR><BR>" Response.Write "<font color=red>INSERIR</font>" exit do end if diario.MoveNext loopend if%>DE CARA VI ESSE ERRO
<%
p_date=request("p_data")
p_edit=("editar")
...
...
if p_date<>"" or p_edit<>"" then
if p_date="" then p_date=cdate("01/01/70") end if
set bd_engespro = server.createObject("ADODB.Connection")
bd_engespro.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../supervisao/database/superv_engespro.mdb") & ";"
set diario = Server.CreateObject("ADODB.RecordSet")
diario.Open "select * from Diario_obra where cod_obra='"&p_cod_obra&"'order by data_ocorrencia", bd_engespro,adOpenDynamic
do while not diario.EOF
if diario("Codigo")=p_edit or diario("data_ocorrencia")=p_date then%>
Já existe Ocorrência nesta Data!
<table WIDTH="80%" ALIGN="center" BORDER="1" CELLSPACING="0" CELLPADDING="0">
<tr>
<td>
<P align=center>Data</P></td>
<td>
<P align=center>Página do Diário</P></td>
<td>
<P align=center>Ocorrência</P></td>
</tr>
<tr>
<td><%= diario("data_ocorrencia")%></td>
<td><P align=center><%= diario("pag_l_obras")%></td>
<%ocorrencia=diario("ocorrencias")%>
<td><%= replace(ocorrencia,chr(13),"<br>")%></td>
</tr>
</table>
<br><font color="red">EDITAR</font>
<br>
<% p_existente = p_date
exit do
end if
if diario.EOF then
Response.Write "Não existe nenhuma Ocorrência nesta Data!<BR><BR>"
Response.Write "<font color=red>INSERIR</font>"
exit do
end if
diario.MoveNext
loop
end if
%>
vê se confere
não sei se é só por isso
Simplesmente não dá erro.Esse cód é parte de uma pg, ele verfica no bd se existe uma data ou um id especifico dentro da seleção, e continua montando a página para inserir, caso não exista, ou editar, caso exista.Ele simplesmente ignora, sendo que sempre existem valores para p_data e p_edit.
testa o que disse acima, trocar nomes de variaveis as vezes não da mensagem de erro mesmo a gente vendo que num ta fazendo o que deveria
Vou testar.
se for só isso você poderia evitar este tipo de erro colocando no topo de saus paginas a linhaoption explicitque exige a definição de todas as variaveis ai quando você trocar algo ele vai dizer que não foi definida e você ver se ja definiu com outro nome ou se não foi definida mesmo
Já testei, e continua não funcionando além de não dar erro.
Achei alguns errinhos de digitação, aí usei o option.explicit declarei as variáveis e... nada.
Ai vai o cód completo.
"Diario_obras_edit_prev.asp"<%@ language="vbscript"%><%option explicitdim p_pagina, p_data, p_edit, p_cod_obra, p_agora, p_username, p_tipo_usuario, p_first, p_existente, bd_engespro, diario p_pagina = "../Administrador/Diario_obras_edit_prev" p_data = Request.Form("p_data")' p_data = trim(Request.Form("p_data"))' p_edit = request("editar") p_edit = Request.Form("editar") p_cod_obra = session("cod_obra") p_agora = Now%><%if Request.Cookies("IsLoggedInAs")="" then Response.Redirect("../Supervisao/Login.asp?p_pagina="&p_pagina) end if p_username = Request.Cookies("IsLoggedInAs")("username")p_tipo_usuario = Request.Cookies("IsLoggedInAs")("t_usuario")p_first = Request.Cookies("IsLoggedInAs")("first_name")if p_tipo_usuario = "3" or p_tipo_usuario = "4" or p_tipo_usuario = "n" then%><!--#include file=../script/adovbs.inc--><!-- #INCLUDE file="../script/barra.txt" --><center><h2>DIÁRIO DE OBRA</h2>Olá <%=p_first%>!<br><font color="red"><b>EDIÇÃO</b></font><br><% if p_data<>"" or p_edit<>"" thenif p_data="" then p_data=cdate("01/01/70") end if set bd_engespro = server.createObject("ADODB.Connection") bd_engespro.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../supervisao/database/superv_engespro.mdb") & ";" set diario = Server.CreateObject("ADODB.RecordSet") diario.Open "select * from Diario_obra where cod_obra='"&p_cod_obra&"'order by data_ocorrencia", bd_engespro,adOpenDynamic do while not diario.EOF if diario("Codigo")=p_edit or diario("data_ocorrencia")=p_data then%>Já existe Ocorrência nesta Data!<table WIDTH="80%" ALIGN="center" BORDER="1" CELLSPACING="0" CELLPADDING="0"> <tr> <td> <P align=center>Data</P></td> <td> <P align=center>Página do Diário</P></td> <td> <P align=center>Ocorrência</P></td> </tr> <tr> <td><%= diario("data_ocorrencia")%></td> <td><P align=center><%= diario("pag_l_obras")%></td> <%ocorrencia=diario("ocorrencias")%> <td><%= replace(ocorrencia,chr(13),"<br>")%></td> </tr></table> <br><font color="red">EDITAR</font><br><% p_existente = p_data exit do end if if diario.EOF then Response.Write "Não existe nenhuma Ocorrência nesta Data!<BR><BR>" Response.Write "<font color=red>INSERIR</font>" exit do end if diario.MoveNext loopend if if p_tipo_usuario="4" or p_tipo_usuario="n" then%><form action="Diario_obras_edit_action.asp" method="post" id="form1" name="form1"><table WIDTH="80%" BORDER="1" CELLSPACING="1" CELLPADDING="1" align="center"> <tr> <td> <% if p_existente = "" then%> <input id="text1" name="p_data" value="<%=p_data%>"> <% else%> <input id="text1" name="p_data" value="<%=p_data%>" disabled> <% end if%> </td> <td> Data (dd/mm/aa) </td> </tr> <tr> <td> <% if p_existente = "" then%> <input id="text1" name="p_livro" > <% else%> <input id="text1" name="p_livro" value="<%= diario("pag_l_obras")%>" disabled> <% end if%> </td> <td> Página do Diário de Obra </td> </tr> <tr> <td><TEXTAREA id=textarea1 style="WIDTH: 355px; HEIGHT: 75px; align: left" name=p_ocorrencia rows=4 cols=38><% if p_existente <> "" then%><%=ocorrencia%><% end if%></TEXTAREA> </td> <td> Descrição da Ocorrência </td> </tr> <tr> <td colspan="2"><center> <input type="submit" value="Enviar" id="submit1" name="submit1"></center> </td> </tr></table><input type="hidden" name="p_data_inser" value="<%=p_agora%>"><input type="hidden" name="p_cod_obra" value="<%=p_cod_obra%>"><input type="hidden" name="p_existente" value="<%=p_existente%>"></form><% else%>Desculpe, mas o seu nível de autorização não permite a utilização deste recurso!<br>Procure seu supervisor ou clique <A HREF="../Supervisao/Login.asp">AQUI</A>!<% end if%></CENTER><% diario.Close set diario = Nothing bd_engespro.Close set bd_engespro = Nothing%><%else%><TABLE WIDTH=760 ALIGN=center BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR> <TD align=center>Desculpe, mas o seu nível de autorização não permite a utilização deste recurso!<br>Entre em contato <A href="../Html/mail.asp">Aqui</A>! </TD> </TR></TABLE><%end if%></BODY></html>A anterior com o frm
"Diario_obras_edit2.asp"<%@ language="vbscript"%><%Response.Buffer=true%><%p_pagina = "../Adminidtrador/Diario_obras_edit2"%><%p_cod_obra = session("cod_obra") p_act=request("action")%><%if Request.Cookies("IsLoggedInAs")="" then Response.Redirect("../Supervisao/Login.asp?p_pagina="&p_pagina) end if p_username = Request.Cookies("IsLoggedInAs")("username")p_tipo_usuario = Request.Cookies("IsLoggedInAs")("t_usuario")p_first = Request.Cookies("IsLoggedInAs")("first_name")if p_tipo_usuario = "3" or p_tipo_usuario = "4" or p_tipo_usuario = "n" then%><!-- #INCLUDE file="../script/barra.txt" --><center><h2>DIÁRIO DE OBRA</h2>Olá <%=p_first%>!<br><% set bd_engespro = server.createObject("ADODB.Connection") bd_engespro.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../Supervisao/database/superv_engespro.mdb") & ";" sql="select * from Cod_obra where cod_obra='"&p_cod_obra&"'" set userSet = bd_engespro.Execute(sql) if not userSet.EOF then%><TABLE WIDTH=760 ALIGN=center BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR> <TD ALIGN=center><%=userSet("cod_obra")%></TD> <TD ALIGN=left><%=userSet("descricao")%></TD> <TD ALIGN=center><%=userSet("data_insert")%></TD> </TR></TABLE><BR><% else Response.Clear Response.Redirect "Admin.asp"%> <%end if set userSet= nothing%><font color="red"><b>ESCRITA</b></font><br><form action="Diario_obras_edit_prev.asp" method="post" id="form1"><input style="WIDTH: 100px; HEIGHT: 22px" size="12" name="p_data">Digite a data que deseja <b>Preencher</b>.<br><input type="submit" value="Preencher" id="submit1" name="submit1"></FORM><br><% set diario = Server.CreateObject("ADODB.RecordSet") diario.Open "select * from Diario_obra where cod_obra='"&p_cod_obra&"' order by data_ocorrencia desc", bd_engespro,adOpenDynamic if diario.EOF=false or diario.BOF=false then%> <form action="Diario_obras_edit_prev.asp" method="post" id="form1"><INPUT type="submit" value="Editar" id=submit2 name=submit2><br><table WIDTH=760 ALIGN="center" BORDER="1" CELLSPACING="0" CELLPADDING="0"> <tr><% if p_act="edt" or p_tipo_usuario = "4" or p_tipo_usuario = "n" then%> <td align=center> Editar </td><% end if%> <td> <P align=center width=30>Data</P></td> <td> <P align=center width=80>Página do Diário</P></td> <td> <P align=center width=650>Ocorrência</P></td> </tr><% while not diario.EOF%> <tr><% if p_act="edt" or p_tipo_usuario = "4" or p_tipo_usuario = "n" then%> <td align=center> <INPUT type="radio" id=radio1 name=editar value=<%=diario("codigo")%>><%=diario("codigo")%> </td><% end if%> <td><%= diario("data_ocorrencia")%></td> <td><P align=cen8ter><%= diario("pag_l_obras")%></td> <td><%= replace(diario("ocorrencias"),chr(13),"<br>")%></td> </tr><% diario.Movenext'Previous wend%></table></form><% else%>Não existe nada no Diário da Obra<% end if diario.Close set diario = Nothing bd_engespro.Close set bd_engespro = Nothing%></center><%else%><TABLE WIDTH=760 ALIGN=center BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR> <TD align=center>Desculpe, mas o seu nível de autorização não permite a utilização deste recurso!<br>Entre em contato <A href="../Html/mail.asp">Aqui</A>! </TD> </TR></TABLE><%end if%></BODY></html>set diario = Server.CreateObject("ADODB.RecordSet")diario.Open "select from Diario_obra where cod_obra='"&p_cod_obra&"'order by data_ocorrencia", bd_engespro,adOpenDynamiccod_obra='"&p_cod_obra&"' <-- se este campo for índice, retire as aspas simples.cod_obra="&p_cod_obra&"Tenta e depois me fala. Se continuar o problema, faça o seguinte antes de setar o recordset.sql = "select from Diario_obra where cod_obra='"&p_cod_obra&"'order by data_ocorrencia" response.write sqlresponse.endDepois posta o que escrever na tela, só para sabermos o q você está passando na instrução SQL. Ok?
O negócio é que não dá erro, parece que simplesmente não atende o if e continua montando a pág.a instr sql é"select * from Diario_obra where cod_obra='BR-TESTE' order by data_ocorrencia".
tem o if da data, né? você quer que se existir algum registro com aquela data, ele exiba o conteúdo e dê a opção de editar?
Ae galera consegui resolver.Apesar de ser meio dificil de entender o que estava errado.Tipo assim esse if<b>if diario("Codigo")=p_edit or diario("data_ocorrencia")=cdate(p_data) then</B>Apesar de estar aparentemente certo, os tipos de dados serem iguaisdiario("Codigo") = inteiro longop_edit = inteiro longodiario("data_ocorrencia") = datacdate(p_data) = dataNão atende nunca, ou seja é sempre diferentee esse outro:<b>if diario("Codigo")-p_cod=0 or diario("data_ocorrencia")-cdate(p_data)=0 then</b>Atender é meio loucura.Obrigado Marioufpa e J.Filho.QQ duvida pode deixar que eu posto aqui.Valeu?
Cara,eu até imprimi o teu código!!! :angry: Quando for assim, além de postar a linha com o erro ou a página, seria legal se postassem como está montada a tabela. Fica mais fácil entender... Como no seu caso.Já tava sonhando com esse erro... :P
Mas é difícil mesmo...tem certas coisas que falar é fácil mas passar pro papel é difícil... Boa sorte kra!
qual o erro que tá dando??