Foros del Web » Programando para Internet » ASP Clásico »

Problema con consulta sql

Estas en el tema de Problema con consulta sql en el foro de ASP Clásico en Foros del Web. hola espero que alguien me pueda orientar, porque no me sale estas consultas, solo una y no se porque o en que estoy mal si ...
  #1 (permalink)  
Antiguo 30/01/2008, 17:11
 
Fecha de Ingreso: septiembre-2007
Mensajes: 93
Antigüedad: 16 años, 7 meses
Puntos: 0
Pregunta Problema con consulta sql



hola espero que alguien me pueda orientar, porque no me sale estas consultas, solo una y no se porque o en que estoy mal
si alguien me puede asesorar; plisssssss

Cita:
<%
'declaracion de variables
dim Vigente,Tramite,Caduca
'variable enviada por el formulario
estado=ucase(trim(request.Form("estado")))
'conexion con la base de datos

set oConn=Server.CreateObject("ADODB.Connection")
strcon=x
if estado<>"Vigente" then
sql="select estado from Prop_Ind where estado='vigente'"
set Rs=oConn.execute(SQL)
end if
if err=0 then
while Rs.EOF=false
Vigente=Vigente+1
rs.movenext
wend

%>Vigentes<%response.write(Vigente)&"<br/>"

elseif estado<>"Tramite" then
sql="select estado from Prop_Ind where estado='Tramite'"
set Rs=oConn.execute(SQL)
end if
if err=0 then
while Rs.EOF=false
Tramite=Tramite+1
rs.movenext

wend

%>Tramite<%response.write(Tramite)&"<br/>"
else
if estado<>"Caduca" then
sql="select estado from Prop_Ind where estado='Caduca'"
set Rs=oConn.execute(SQL)
end if
if err=0 then
while Rs.EOF=false
Caduca=Caduca+1
rs.movenext
wend

%>Caduca<%response.write(Caduca)&"<br/>"

Rs.Close
Set RS=nothing
oConn.Close
set oConn=nothing
end if
end if
%>
  #2 (permalink)  
Antiguo 31/01/2008, 07:58
Avatar de a n g e l u s  
Fecha de Ingreso: enero-2006
Ubicación: Chile
Mensajes: 237
Antigüedad: 18 años, 3 meses
Puntos: 1
Re: Problema con consulta sql

HOLA QUE TAL

LOS problemas, asi al ojo son en las siguentes lineas:

sql="select estado from Prop_Ind where estado= ' " & vigente & " ' "


sql="select estado from Prop_Ind where estado= ' " & tramite & " ' "


sql="select estado from Prop_Ind where estado= ' " & caduca & " ' "
__________________
Atte,
A n g e l u s
Concepción - Chile
más vale respuestas bien pensadas, que 7000 post
  #3 (permalink)  
Antiguo 31/01/2008, 08:41
Avatar de Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 3 meses
Puntos: 126
Re: Problema con consulta sql

Prueba así

kmesta=ucase(trim(request.Form("estado")))

Sta = 0

set oConn=Server.CreateObject("ADODB.Connection")
sql="select estado from Prop_Ind where estado='&kmesta&'"
set Rs=oConn.execute(SQL)
if err=0 then
while Rs.EOF=false
if kmesta = "vigente" then Sta = Sta+1
if kmesta = "tramite" then Sta = Sta+1
if kmesta = "caduca" then Sta = Sta+1
rs.movenext
wend
Response.Write kmesta & Sta
else
.....


Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />
  #4 (permalink)  
Antiguo 31/01/2008, 10:16
 
Fecha de Ingreso: septiembre-2007
Mensajes: 93
Antigüedad: 16 años, 7 meses
Puntos: 0
Re: Problema con consulta sql

Cita:
Iniciado por Adler Ver Mensaje
Prueba así

kmesta=ucase(trim(request.Form("estado")))

Sta = 0

set oConn=Server.CreateObject("ADODB.Connection")
sql="select estado from Prop_Ind where estado='&kmesta&'"
set Rs=oConn.execute(SQL)
if err=0 then
while Rs.EOF=false
if kmesta = "vigente" then Sta = Sta+1
if kmesta = "tramite" then Sta = Sta+1
if kmesta = "caduca" then Sta = Sta+1
rs.movenext
wend
Response.Write kmesta & Sta
else
.....


Suerte

ya probe tu programa este de plano no me muestra nadaaaaaaaaa
y la verdad es que si tengo registros en mi base de datos
asi que??????????
  #5 (permalink)  
Antiguo 31/01/2008, 11:25
 
Fecha de Ingreso: septiembre-2007
Mensajes: 93
Antigüedad: 16 años, 7 meses
Puntos: 0
Re: Problema con consulta sql


Hola ya me quedo muchas gracias por la ayuda
el codigo quedo asi, solo era cuestion de quitar los else, jaaaaaaa
siempre suele pasar que por algo tan sencillo se nos complica todoo

Cita:
<%
'declaracion de variables
dim Vigente,Tramite,Caduca
'variable enviada por el formulario
estado=ucase(trim(request.Form("estado")))
'conexion con la base de datos

set oConn=Server.CreateObject("ADODB.Connection")
strcon=x
oConn.Open strcon
if estado<>"Vigente" then
sql="select estado from Prop_Ind where estado='vigente'"
set Rs=oConn.execute(SQL)
end if
if err=0 then
while Rs.EOF=false
Vigente=Vigente+1
rs.movenext
wend
%>Vigentes<%response.write(Vigente)&"<br/>"

if estado<>"Tramite" then
sql="select estado from Prop_Ind where estado='Tramite'"
set Rs=oConn.execute(SQL)
end if
if err=0 then
while Rs.EOF=false
Tramite=Tramite+1
rs.movenext
wend
%>Tramite<%response.write(Tramite)&"<br/>"

if estado<>"Caduca" then
sql="select estado from Prop_Ind where estado='Caduca'"
set Rs=oConn.execute(SQL)
end if
if err=0 then
while Rs.EOF=false
Caduca=Caduca+1
rs.movenext
wend

%>Caduca<%response.write(Caduca)&"<br/>"

Rs.Close
Set RS=nothing
oConn.Close
set oConn=nothing
end if
end if
end if
%>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:46.