Jump to content


Photo

Problemas Com If


  • Faça o login para participar
4 replies to this topic

#1 Brunao

Brunao

    Normal

  • Usuários
  • 70 posts
  • Sexo:Não informado

Posted 08/07/2005, 12:19

Boa Tarde galera.
Estou com uma dúvida que julgo ser muito idiota, pois sou programador a muito tempo, mas fiquei um ano sem programar e to tendo muita dificuldade nisso.
Acontece o seguinte:
Eu tenho essa página ASP, que busca informações no BD, a página funciona corretamente, porém quero fazer um IF que veja se o campo RESPONSAVEL no BD estiver vazio ele não escreve nada.

Valeu, Galera!!!!


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<style type="text/css">
<!--
.style10 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
}
.style11 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #006666;
	font-weight: bold;
	font-size: 15px;
}
body {
	background-color: #EEEEEE;
}
a:link {
	color: #006666;
}
a:visited {
	color: #006666;
}
a:hover {
	color: #006666;
}
a:active {
	color: #006666;
}
-->
</style>

<%id= request.QueryString("id")%>
<%
Dim DB
set DB = Server.CreateObject("ADODB.Connection")
DB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("../data/db_site.MDB") 
DB.mode = adModeRead
DB.open
Set rs = DB.Execute("SELECT * FROM casa_noturna WHERE id = "&id)

%>
	<table width="600"  border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <tr>
    <td bgcolor="#eeeeee"><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#CCFF00">
      <tr>
        <td valign="top"><table width="100%" height="10"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td></td>
          </tr>
        </table>          
          <table width="598" height="100"  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="9" height="100"></td>
              <td width="170"><img src="imagens/<%=rs.fields("logo")%>" width="170" height="100"></td>
              <td width="9"></td>
              <td width="398" align="left" valign="top"><span class="style11"><strong><%=rs.fields("estabelecimento")%></strong></span><br>
                <span class="style10"><%=rs.fields("endereco")%> - <%=rs.fields("bairro")%><br>
                (<%=rs.fields("ddd")%>) <%=rs.fields("tel1")%> | (<%=rs.fields("ddd")%>) <%=rs.fields("tel2")%><br>
                <%=rs.fields("cidade")%> - <%=rs.fields("estado")%></span>
    
    </td>
              <td width="12">&nbsp;</td>
            </tr>
          </table>          
          <table width="100%" height="10"  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td></td>
            </tr>
          </table></td>
      </tr>
    </table>      
      <table width="100%" height="1"  border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
        <tr>
          <td></td>
        </tr>
      </table>      
      <table width="598"  border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="10" height="19">&nbsp;</td>
          <td width="578"><span class="style10"><%=rs.fields("sobre")%> <br>
            [COLOR=red]<%if rs.fields("responsavel") = "" then%>
 	 <%else%>
 	 <strong>Respons&aacute;vel:</strong> <%=rs.fields("responsavel")%> <br>
            <%end if%>[/COLOR] 	<strong>Site:</strong> <a href="<%=rs.fields("site")%>"><%=rs.fields("site")%></a> <br>
            <strong>Email:</strong> <a href="mailto:<%=rs.fields("email")%>"><%=rs.fields("email")%></a> <br>
            <strong>Capacidade:</strong> <%=rs.fields("capacidade")%><br>
            <strong>Ambientes:</strong> <%=rs.fields("ambientes")%></span> </td>
          <td width="10">&nbsp;</td>
        </tr>
      </table>      </td>
  </tr>
</table>
	
	

    
   <%
rs.Close
SET rs = NOTHING
SET DB = NOTHING
%>
</body>
</html>

Edição feita por: Brunao, 08/07/2005, 12:22.

1000 % ASP

#2 koal40

koal40

    agora em PHP tbm

  • Usuários
  • 216 posts
  • Sexo:Não informado

Posted 08/07/2005, 12:30

deixa eu ver se intendi...

ASP:

com a variavel problema, vc pode checar diferentes campos vazios

<%problema = 0

if rs("responsavel") = "" then
problema = 1
else
'insira os dados
end if


if problema = 1 then
'função qualquer
else%>

'pagina completa

<%end if%>

OU

<%if rs("responsavel") <> "" then%>
pagina
<%else
response.write("o campo responsavel não existe")
end if%>


OU

<%if len(rs("responsavel")) > 1 then%>
pagina
<%else
response.write("o campo responsavel não existe")
end if%>


Edição feita por: koal40, 08/07/2005, 12:35.

Ultilize a busca antes de postar
e edite respostas não poste d novo...

(sempre q possivel claro)
------------ Conhecimento ----------
HTML ...... ||||||||||
JSP e JS .. ||||||||||
.NET ....... ||||||||||
ASP ........ ||||||||||
PHP ........ ||||||||||
Ourtos .... ||||||||||

#3 Brunao

Brunao

    Normal

  • Usuários
  • 70 posts
  • Sexo:Não informado

Posted 08/07/2005, 13:04

Obrigado pela atenção, mas infelizmente não funcionou, ele não tá colhendo a informação no BD eu acho. Esse campo responsavel é um campo texto.
Ele sempre da Falso ou seja ELSE.

teste 1
<%teste=1%>
<%if rs.fields("responsavel") = "" then%>
<%=teste%>
<%else%>
pagina completa
<%end if%>

teste 2
<%teste=1%>
<%if rs("responsavel") = "" then%>
<%=teste%>
<%else%>
pagina completa
<%end if%>

Edição feita por: Brunao, 08/07/2005, 13:07.

1000 % ASP

#4 koal40

koal40

    agora em PHP tbm

  • Usuários
  • 216 posts
  • Sexo:Não informado

Posted 08/07/2005, 13:24

ele sempre diz q tem coisa escrita, mas não tem?

vc tentou isso:

<%if len(rs("responsavel")) > 1 then%>
pagina
<%else
response.write("o campo responsavel não existe")
end if%>

???
Ultilize a busca antes de postar
e edite respostas não poste d novo...

(sempre q possivel claro)
------------ Conhecimento ----------
HTML ...... ||||||||||
JSP e JS .. ||||||||||
.NET ....... ||||||||||
ASP ........ ||||||||||
PHP ........ ||||||||||
Ourtos .... ||||||||||

#5 Brunao

Brunao

    Normal

  • Usuários
  • 70 posts
  • Sexo:Não informado

Posted 08/07/2005, 13:36

Com o Len funcionou, mas que zica essa xxxxxx de BD informar que o campo tem informações se está vazio.
Enfim, problema solucionado, obrigado pela força, mas mesmo assim vou tentar descobrir pq essa xxxxxx informa errado.

Obrigado
1000 % ASP




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq