
05/11/2007, 20:42
|
| | Fecha de Ingreso: octubre-2007
Mensajes: 191
Antigüedad: 17 años, 6 meses Puntos: 0 | |
Re: Exportar una consulta asp con sql 2000 a Excel compadre.........te sigo agradeciendo tu paciencia.....pero aun tengo problemas......resulta que ahora si funciona el boton.....pero me abre una ventana nueva de internet explorer....o sea no me genera el archivo excel......
y mas encima me trae TODOS los registros de la Bdd y no los que yo consulto......AYUDA POR FAVOR!!!!! 
no se si sera que me equivoco yo en algo del codigo......pero por si te sirve para saber cual es el error.....este es el codigo:
VAL_BUSCAR.ASP : Cita: <HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<FORM ACTION='val_buscar.asp' METHOD='GET' id=form1 name=form1>
<script>
function AbrirVentana(ventana)
{
window.open(ventana,"Consulta","left=25,top=25,too lbar=0,location=1,directories=0,status=1,menubar=0 ,scrollbars=1,resizable=0,copyhistory=0,width=750, height=650")}
</script>
</HEAD>
<body bgcolor="#FFCC66" background="2.jpg" text="BLACK" link="BLACK" vlink="BLACK" alink="BLACK">
<p align="center">
<%
if request.QueryString("extra")="1" then
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition", "inline; filename=Consulta.xls"
strSQL=session("SQL_para_EXCEL")
else
'aca recibo los campos que voy a realizar la busqueda
csr = Request.form("csr")
nombre_cliente = Request.form("nombre_cliente")
serie = Request.form("serie")
estado = Request.form("estado")
tecnico = Request.form("tecnico")
On Error Resume next
Const adCmdText = &H0001
Const adOpenStatic = 3
'declaro las variables a utilizar incluyendo la se_encuentra
Dim Rs, Cnn, SQL
set Cnn=Server.CreateObject("ADODB.Connection")
set rs=Server.CreateObject("ADODB.Recordset")
Cnn.Open Session("cnx")
'ejecuto la consulta
strSQL="SELECT *, DateDiff (day, fecha_in ,fecha_ret) as difes, DATEDIFF (DAY, fecha_in, getdate()) as difftot FROM tblcliente"
se_encuentra = False
if se_encuentra then
strSQL=strSQL & " AND tipo_cliente LIKE '%cliente'"
else
strSQL=strSQL & " WHERE tipo_cliente LIKE '%cliente'"
se_encuentra=True
end if
if csr <> "" then
if se_encuentra then
strSQL=strSQL & " AND csr LIKE '%"&csr&"'"
else
strSQL=strSQL & " WHERE csr LIKE '%"&csr&"'"
se_encuentra=True
end if
end if
'la variable se_encuentra se inicializa en falso y se cambia a verdadero si el campo trae un valor ingresado
if distribuidor <> "" then
if se_encuentra then
strSQL=strSQL & " AND nombre_cliente LIKE '%"&nombre_cliente&"'"
else
strSQL=strSQL & " WHERE nombre_cliente LIKE '%"&nombre_cliente&"'"
se_encuentra=True
end if
end if
if serie <> "" then
if se_encuentra then
strSQL=strSQL & " AND serie LIKE '%"&serie&"'"
else
strSQL=strSQL & " WHERE serie LIKE '%"&serie&"'"
se_encuentra=True
end if
end if
if estado <> "" then
if se_encuentra then
strSQL=strSQL & " AND estado LIKE '%"&estado&"'"
else
strSQL=strSQL & " WHERE estado LIKE '%"&estado&"'"
se_encuentra=True
end if
end if
if tecnico <> "" then
if se_encuentra then
strSQL=strSQL & " AND tecnico LIKE '%"&tecnico&"'"
else
strSQL=strSQL & " WHERE tecnico LIKE '%"&tecnico&"'"
se_encuentra=True
end if
end if
session("SQL_para_EXCEL")=strSQL
end if
rs.Open strSQL, Cnn,adopenstatic,adcmdtext
'abrimos la tabla para llamar los registros
if rs.EOF then
Response.Write("No existe el campo ingresado, verifique los datos")
else %>
<br>
<font face="Bookman Old Style"><em>Número de registros seleccionados:</em></font> <b><%=RS.RecordCount%></b>
<p align="center">
<CENTER>
<TABLE WIDTH=1000height="61" BORDER=1 align="center" CELLSPACING="0">
<tr> <td width=74 bordercolor="#F0F0F0" bgcolor="ORANGE"><center><b>Csr</b></center>
<td width=60 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><b>Nombre Cliente</b></center>
<td width=73 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><b>Fecha Ingreso</b></center>
<td width=122 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><b>Artefacto</b></center>
<td width=83 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><b>Serie</b></center>
<td width=95 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><b>Estado</b></center>
<td width=72 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><p><b>Fecha </b><b>Status</b></p></center>
<td width=59 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><b>Tipo de Garantia</b></center>
<td width=76 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><b>Tecnico Asignado</b></center>
<td width=74 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><b>Diferencia Dias Status</b></center>
<td width=74 bordercolor="#FFFFFF" bgcolor="ORANGE"><center><b>Diferencia Dias Total</b></center>
</tr> </table> </CENTER>
<%do while not rs.EOF%>
<center>
<TABLE BORDER=1 CELLSPACING="0" WIDTH=1000>
<tr>
<%Response.Write "<td WIDTH=80 align='center' >"&rs("csr")&"<td WIDTH=100 align='center'>"&rs("nombre_cliente")&"<td WIDTH=99 align='center'>"&rs("fecha_in")&"<td WIDTH=134 align='center'>"&rs("artefacto")&"<td WIDTH=100 align='center' >"&rs("serie")&"<td WIDTH=80 align='center' >"&rs("estado")&"<td WIDTH=102 align='center' >"&rs("fecha_avi")&"<td WIDTH=102 align='center' >"&rs("fecha_ret")&"<td WIDTH=70 align='center' >"&rs("gtia")&"<td WIDTH=100 align='center' >"&rs("tecnico")&"<td WIDTH=100 align='center' >"&rs("difes")&"<td WIDTH=90 align='center' >"&rs("difftot")%>
<br> </tr>
<%rs.Movenext%>
</table></center>
<%loop
end if
rs.Close
set rs = nothing
Cnn.Close
set oCnn = nothing
%>
<h3> <center> <a href="javascript:AbrirVentana('val_buscar.asp?extr a=1');">EXCEL</a>
</center> </h3>
<br> <br> <font face="Verdana">
<h3> <center> <a href="../buscar_clie.asp">Buscar Otro</a> </center> </h3>
</font>
<br> <br> <font face="Verdana">
<h3> <center> <a href="../menu.asp">Volver al Menu</a> </center> </h3>
</font>
</body>
</html>
Última edición por darkmcloud; 06/11/2007 a las 07:59 |