
10/11/2002, 19:11
|
| | Fecha de Ingreso: noviembre-2002
Mensajes: 133
Antigüedad: 22 años, 6 meses Puntos: 0 | |
SOS, muy importante. Gracias Hola, con este codigo pretendo tener 2selecciones: uno y dos (son mas selecciones, pero lo resumo en 2), con cada una de ellas busca en la base de datos los nombres de las tablas y su
codigo de cada usuario cuyo criterio de busqueda es que sea el mismo usuario y con la misma opcion.
Todas las tablas contienen a los mismos usuarios, lo unico que cambia es la opcion que guardan (opcion = 1, opcion = 2), y el codigo, utilizo esta estructura que esta simplificada, por lo que es importante esta estructura de multiples tablas aunque se repitan los usuarios
Gracias
<%
Option Explicit
Dim sql, rsIdentifs, username, opcion
username = Request.Cookies("username")
opcion = Request.QueryString("opcion")
%>
<%
Dim ConnectString, conn
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("siteusers.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnectString
%>
<%
'Opcion 1
If opcion = "uno" then
sql = "SELECT 'tabla1' as Listado , codigo FROM tabla1 WHERE tabla1.username = '" & username & "' AND TABLA1.OPCION = 1 UNION SELECT 'tabla2' as Listado , codigo FROM tabla2 WHERE tabla2.username = '" & username & "' AND TABLA2.OPCION = 1 UNION SELECT 'tabla3' as Listado , codigo FROM tabla3 WHERE tabla3.username = '" & username & "' AND TABLA3.OPCION = 1 UNION SELECT 'tabla4' as Listado , codigo FROM tabla4 WHERE tabla4.username = '" & username & "' AND TABLA1.OPCION = 1 UNION SELECT 'tabla5' as Listado , codigo FROM tabla5 WHERE tabla5.username = '" & username & "' AND TABLA2.OPCION = 1"
end if
'Opcion 2
If opcion = "dos" then
sql = "SELECT 'tabla1' as Listado , codigo FROM tabla1 WHERE tabla1.username = '" & username & "' AND TABLA1.OPCION = 2 UNION SELECT 'tabla2' as Listado , codigo FROM tabla2 WHERE tabla2.username = '" & username & "' AND TABLA2.OPCION = 2 UNION SELECT 'tabla3' as Listado , codigo FROM tabla3 WHERE tabla3.username = '" & username & "' AND TABLA3.OPCION = 2 UNION SELECT 'tabla4' as Listado , codigo FROM tabla4 WHERE tabla4.username = '" & username & "' AND TABLA1.OPCION = 2 UNION SELECT 'tabla5' as Listado , codigo FROM tabla5 WHERE tabla5.username = '" & username & "' AND TABLA2.OPCION = 2"
end if
Set rsIdentifs = Server.CreateObject("ADODB.Recordset")
rsIdentifs.Open sql, conn, 3, 3
%>
<!-- Displays opcions -->
<table cellpadding=4 cellspacing=1 border=0 bgcolor="#000000">
<tr>
<td align="center" bgcolor="#F3F3F3" width="17"><font face="arial,helvetica" size="2"><b><a href="prueba.asp?opcion=uno">Opcion uno</a></b></font>
<td align="center" bgcolor="#F3F3F3" width="17"><font face="arial,helvetica" size="2"><b><a href="prueba.asp?opcion=dos">Opcion dos</a></b></font>
</tr>
</table>
<%if not rsIdentifs.EOF then%>
<!-- Identif users -->
<table cellpadding=4 cellspacing=1 border=0 bgcolor="#000000">
<tr>
<th width="272"><font face="arial,helvetica" size="1" color="#FFFFFF">Username</font></th>
<th width="70"><font face="arial,helvetica" size="1" color="#FFFFFF">Codigo</font></th>
</tr>
<%rsIdentifs.Movefirst
do until rsIdentifs.EOF%>
<tr bgcolor="#F3F3F3">
<td><font face="arial,helvetica" size="2"><%=rsIdentifs("username")%></font></td>
<td><font face="arial,helvetica" size="2"><%=rsIdentifs("codigo")%></font></td>
</tr>
<%rsIdentifs.Movenext
loop%>
</table>
<html>
<head>
<title>User List</title>
</head>
<body bgcolor="#FFFFFF" link="#DD0000" vlink="#DD0000" alink="#000000">
</body>
</html>
<%
rsIdentifs.close
set rsIdentifs = nothing
conn.close
set conn = nothing
%> |