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

¿Qué hay mal aquí?

Estas en el tema de ¿Qué hay mal aquí? en el foro de ASP Clásico en Foros del Web. Código: sql = "SELECT * FROM Noticias WHERE id=" & Request.QueryString("id") & " & categoria=" &Request.QueryString("categoria") & "" ¿Qué hay mal? Sospecho de ese & ...
  #1 (permalink)  
Antiguo 25/08/2002, 20:01
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 23 años, 3 meses
Puntos: 29
¿Qué hay mal aquí?

Código:
sql = "SELECT * FROM Noticias WHERE id=" & Request.QueryString("id") & " & categoria=" &Request.QueryString("categoria") & ""
¿Qué hay mal? Sospecho de ese & antes de categoria=".... pero no sé como ponerlo.

saludos.

<center><hr size="1" color="blue" width="39%"><a href="http://www.ommadawn.es.vg" target="_blank"><font color="red">www.Ommadawn.es.vg[/CODE]</a><hr size="1" color="blue" width="39%">
  #2 (permalink)  
Antiguo 25/08/2002, 20:06
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 23 años, 3 meses
Puntos: 29
Re: ¿Qué hay mal aquí?

Pasen de eso por favor, qué hay de mal aquí (este sí):

SQL=&quot;SELECT * FROM Noticias WHERE categoria=&quot; &amp; Request.QueryString(&quot;categoria&quot;) &amp; &quot; ORDER BY id DESC;&quot;

gracias

<center><hr size="1" color="blue" width="39%"><a href="http://www.ommadawn.es.vg" target="_blank"><font color="red">www.Ommadawn.es.vg[/CODE]</a><hr size="1" color="blue" width="39%">
  #3 (permalink)  
Antiguo 25/08/2002, 20:17
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 23 años, 3 meses
Puntos: 29
Re: ¿Qué hay mal aquí?

Yo les paso todo el código por si quieren mirar el error lo pongo abajo:

Código:
&lt;%
Dim oConn, rs, SQL
Dim PaginaActual
Dim PaginasTotales
Dim TamPagina
Dim CuantosRegistros
TamPagina=1

if Request.Querystring(&quot;pagina&quot;)=&quot;&quot; then
PaginaActual=1
else
PaginaActual=CInt(Request.Querystring(&quot;pagina&quot;))
end if

set oConn=Server.CreateObject(&quot;ADODB.Connection&quot;)
set rs=Server.CreateObject(&quot;ADODB.Recordset&quot;)

oConn.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0; &quot; &amp; _
&quot;Data Source=&quot;&amp;Server.MapPath(&quot;******.mdb&quot;)&amp;&quot;;&quot;
SQL=&quot;SELECT * FROM Noticias WHERE categoria=&quot; &amp; Request.QueryString(&quot;categoria&quot;) &amp; &quot; ORDER BY id DESC;&quot;

rs.PageSize=TamPagina
rs.CacheSize=TamPagina

rs.Open SQL, oConn, 1, 2
PaginasTotales=rs.PageCount

if PaginaActual &lt; 1 then 
PaginaActual = 1
end if
if PaginaActual &gt; PaginasTotales then
PaginaActual = PaginasTotales
end if
if PaginasTotales=0 then

Response.Write(&quot;No se encontraron resultados.&quot;)

else

rs.AbsolutePage=PaginaActual
Response.Write(&quot;Pagina &quot; &amp; PaginaActual &amp; &quot; de &quot; &amp; PaginasTotales)
CuantosRegistros=0
do while not rs.EOF and CuantosRegistros &lt; TamPagina
Response.Write &quot;&lt;p&gt;&lt;b&gt;&lt;font face=Verdana size=1&gt;&lt;a href=noticia.asp?id=&quot; &amp;rs.Fields(&quot;id&quot;) &amp; &quot;&gt;&quot;&amp;rs.Fields(&quot;titulo&quot;)&amp;&quot;&lt;/a&gt;&lt;/b&gt;&lt;br&gt;&lt;font color=#696969&gt;&amp;#149; &quot; &amp;rs.Fields(&quot;copete&quot;) &amp; &quot;&lt;/font&gt;&lt;/font&gt;&quot;		
CuantosRegistros=CuantosRegistros+1
rs.MoveNext
loop
Response.Write(&quot;&lt;/p&gt;&quot;)
end if
rs.Close
oConn.Close
set rs=nothing
set oConn=nothing

Response.Write(&quot;&lt;hr&gt;&quot;)
if PaginaActual &gt; 1 then
Response.Write(&quot;&lt;A HREF=listados.asp?pagina=&quot;&amp; PaginaActual-1&amp; _
&quot;&gt;Anterior&lt;/A&gt;&quot;)
end if
if PaginaActual &lt; PaginasTotales then
Response.Write(&quot;&lt;A HREF=listados.asp?pagina=&quot; &amp; PaginaActual+1 &amp; _ 
&quot;&gt;Siguiente&lt;/A&gt;&quot;)
end if
%&gt;
Error:
Código:
Microsoft JET Database Engine error '80040e10' 

No value given for one or more required parameters. 

/ommadawn/db/noticias/listados.asp, line 37
<center><hr size="1" color="blue" width="39%"><a href="http://www.ommadawn.es.vg" target="_blank"><font color="red">www.Ommadawn.es.vg[/CODE]</a><hr size="1" color="blue" width="39%">
  #4 (permalink)  
Antiguo 25/08/2002, 20:19
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 23 años, 3 meses
Puntos: 29
Re: ¿Qué hay mal aquí?

Otro dato por si les ayuda. La página se llama:

listados.asp?pagina=1&amp;categoria=Deportes

<center><hr size="1" color="blue" width="39%"><a href="http://www.ommadawn.es.vg" target="_blank"><font color="red">www.Ommadawn.es.vg[/CODE]</a><hr size="1" color="blue" width="39%">
  #5 (permalink)  
Antiguo 25/08/2002, 21:00
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 23 años, 3 meses
Puntos: 29
Re: ¿Qué hay mal aquí?

Más cosas que les pueden servir para averiguar el error. Si la conexión es:

SQL=&quot;SELECT * FROM Noticias WHERE categoria=&quot; &amp; Request.QueryString(&quot;categoria&quot;) &amp; &quot; ORDER BY id DESC;&quot;

Me da error.
Si es:

SQL=&quot;SELECT * FROM Noticias ORDER BY id DESC;&quot;

Me va perfectamente. Pero quiero que me muestre sólo según la categoría del parámetro por la url.

Espero que comprendan lo que quiero hacer.

saludos y gracias.

<center><hr size="1" color="blue" width="39%"><a href="http://www.ommadawn.es.vg" target="_blank"><font color="red">www.Ommadawn.es.vg[/CODE]</a><hr size="1" color="blue" width="39%">
  #6 (permalink)  
Antiguo 25/08/2002, 22:22
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 23 años, 3 meses
Puntos: 29
Re: ¿Qué hay mal aquí?

Bueno, espero que me contestéis pronto, ahora me voy a dormir pero mañana espero tener una respuesta. es urgente, gracias.

<center><hr size="1" color="blue" width="39%"><a href="http://www.ommadawn.es.vg" target="_blank"><font color="red">www.Ommadawn.es.vg[/CODE]</a><hr size="1" color="blue" width="39%">
  #7 (permalink)  
Antiguo 25/08/2002, 23:24
Avatar de ElAprendiz  
Fecha de Ingreso: enero-2002
Ubicación: Maipu, Chile
Mensajes: 3.706
Antigüedad: 23 años, 3 meses
Puntos: 2
Re: ¿Qué hay mal aquí?

segun lo que logro leer del error es que la variable no tiene un valor..o seas esta vacia..por que no haces un response.write de la sentencia para ver..su contenido..

<center><IMG SRC="http://www.550m.com/usuarios/altolacruz/aprendiz3.gif" ALT="Visitame en AlSurNet.com -- E-Learning E-Commerce Multimedia E-Business--"></center>
  #8 (permalink)  
Antiguo 26/08/2002, 08:28
pny
 
Fecha de Ingreso: marzo-2002
Ubicación: Barcelona
Mensajes: 33
Antigüedad: 23 años, 1 mes
Puntos: 0
Re: ¿Qué hay mal aquí?

Si la categoria está definida en la base de datos como un string, debería ir en la consulta entre comillas simples.

espero te funcione.
  #9 (permalink)  
Antiguo 26/08/2002, 08:33
 
Fecha de Ingreso: junio-2002
Ubicación: Buenos Aires, Argentina
Mensajes: 876
Antigüedad: 22 años, 11 meses
Puntos: 0
Re: ¿Qué hay mal aquí?

Proba esto: al parecer tus categorias no son numeros, por lo tanto deberias poner en vez de categoria=&quot;&amp;xxx&amp;&quot; order
esto:
categoria='&quot;&amp;xxx&amp;&quot;' order
Contanos como te fue
Saludos.
  #10 (permalink)  
Antiguo 26/08/2002, 09:05
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 23 años, 3 meses
Puntos: 29
Re: ¿Qué hay mal aquí?

Funciona, muchas gracias el problema eran las comillas simples.

<center><hr size="1" color="blue" width="39%"><a href="http://www.ommadawn.es.vg" target="_blank"><font color="red">www.Ommadawn.es.vg[/CODE]</a><hr size="1" color="blue" width="39%">
  #11 (permalink)  
Antiguo 26/08/2002, 09:24
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 23 años, 3 meses
Puntos: 29
Re: ¿Qué hay mal aquí?

Hola, hay un problema más, lo que quiero es que muestre el último registro de la bd y me muestra el primero. Tengo la siguiente sentencia:

Código:
&lt;%
Set con = Server.CreateObject(&quot;ADODB.Connection&quot;)
Con.Open(&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; &amp; _
Server.MapPath(&quot;******.mdb&quot;))
sql = &quot;SELECT TOP 1 * FROM Noticias&quot;
set result = Con.Execute(sql)
%&gt;
<center><hr size="1" color="blue" width="39%"><a href="http://www.ommadawn.es.vg" target="_blank"><font color="red">www.Ommadawn.es.vg[/CODE]</a><hr size="1" color="blue" width="39%">
  #12 (permalink)  
Antiguo 26/08/2002, 09:40
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 24 años, 2 meses
Puntos: 535
Re: ¿Qué hay mal aquí?

es que le tenés que dar algún ordenamiento descendente...

sql = &quot;SELECT TOP 1 * FROM Noticias ORDER BY AlgunCampo DESC&quot;
  #13 (permalink)  
Antiguo 26/08/2002, 14:48
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 23 años, 3 meses
Puntos: 29
Re: ¿Qué hay mal aquí?

Gracias dazuaga, FUNCIONA CORRECTAMENTE!!!!!



<center><hr size="1" color="blue" width="39%"><a href="http://www.ommadawn.es.vg" target="_blank"><font color="red">www.Ommadawn.es.vg[/CODE]</a><hr size="1" color="blue" width="39%">
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 06:32.