Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/06/2009, 03:23
kyu24
 
Fecha de Ingreso: mayo-2009
Mensajes: 40
Antigüedad: 15 años, 11 meses
Puntos: 0
Pregunta ayuda con formulario

necesito ayuda con un formulario que estoy haciendo en asp, cojo los los nombres de las tablas que tengo en una tabla el access y y los envio a un select, cuando elijes en el select lo mando a busqueda de tablas segun lo seleccionado pero no me lo reconoce, me dice error de syntax a ver si me podeis ayudar

este es el formulario
Código:
<Select NAME="busca" SIZE=1>
		<% 
		set conexion=server.createobject("ADODB.connection")
		basedatos3="DRIVER=Microsoft Access Driver (*.mdb);DBQ="&Server.MapPath("db/kabbalah.mdb")
		conexion.open basedatos3
		sql="select * from productos where producto order by id asc"
		set r3=conexion.execute(sql)
		Do While Not r3.EOF %>
		<Option VALUE="<%= r3("tabla") %>"><%= r3("producto") %></Option>
		<% r3.MoveNext
			Loop
			r3.Close
		conexion.Close %>
	</Select>
      </label>
    </p>
    <input name="Mostrar" type="submit" value="Mostrar" />
esto es lo que lo recibe
Código:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
	
	<script src="js/prototype.js" type="text/javascript"></script>
	<script src="js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
	<script src="js/lightbox.js" type="text/javascript"></script>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style></head>

<body>
<table width="950" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="300"><img src="images/p6.jpg" width="300" height="418" border="0" usemap="#Map" /></td>
    <td width="650" rowspan="2" align="center" valign="top">
	<%
	categoria1=request.form("busca")
	
        set conexion=server.createobject("ADODB.connection")
	basedatos1="DRIVER=Microsoft Access Driver (*.mdb);DBQ="&Server.MapPath("db/kabbalah.mdb")
	conexion.open basedatos1
	sql="select * from productos where tabla='"&categoria1&"';"
	set tabla=conexion.execute(sql)

	if(categoria1="talismanes") then
%>
<form name="subcategoria" id="subcategoria" method="post" action="buscar2.asp" >
    Seleccione Subcategoria:
    <Select NAME="sub" SIZE=1>
<%
categoria1=request.form("busca")
	set conexion=server.createobject("ADODB.connection")
	basedatos2="DRIVER=Microsoft Access Driver (*.mdb);DBQ="&Server.MapPath("db/kabbalah.mdb")
	conexion.open basedatos2
	sql="select * from subcategoria where id_cat='"&categoria1&"' order by id asc"
	set r2=conexion.execute(sql)
	do while not r2.EOF %>
		<Option VALUE="<%= r3("subcategoria") %>"><%= r3("subcategoria") %></Option>
		<% r2.MoveNext
			Loop
			r2.Close
		conexion.Close %> 
		</Select>	
	
      <input name="Mostrar" type="submit" value="Siguiente" /><input type="button" onclick="javascript:history.back(1)" value="Volver Atras" />
    </form>
        
<%else%>
	    <%
		categoria1=request.form("busca")
        set conexion=server.createobject("ADODB.connection")
	basedatos3="DRIVER=Microsoft Access Driver (*.mdb);DBQ="&Server.MapPath("db/kabbalah.mdb")
	conexion.open basedatos3
	sql="select * from '"&categoria1&"' order by referencia asc"
	set r3=conexion.execute(sql)
	%>
	<table width="100%" border=0 align="center">
	<font face="Arial, Helvetica, sans-serif" size=2>
	<strong>
	<tr align="center">
	<td width="15%">REFERENCIA</td>
	<td width="18%">NOMBRE</td>
	<td width="23%">PRECIO</td>
	<td width="18%">FOTO</td>
</tr>
</strong>
<% do while not r3.EOF %>
<tr align="center">
<td><%=r3("referencia")%>
<td><%=r3("producto")%>
<td><%=r3("precio")%> €
<td><a href="images/<%=r3("imagen")%>" target="_blank" rel="lightbox"><img src="images/<%=r3("imagen")%>" width="100" height="100" border="0"></a></tr>
<% 
	r3.movenext
	loop
	conexion.close
	%>
       
		 <%end if%> </table>  

    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
como veis mando el select del formulario al sql SELECT * FROM ........... para seleccionar la tabla elejida anteriormente.

el error es

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in query. Incomplete query clause.

/kyu21/buscar.asp, line 67

gracias

Última edición por kyu24; 11/06/2009 a las 00:44