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

Para Myakire:(crystal report)

Estas en el tema de Para Myakire:(crystal report) en el foro de ASP Clásico en Foros del Web. Gente del foro: disculpen si desvio esta pregunta a Myakire, la razon, parece conocer mucho del tema y me puede colaborar. Si alguien mas me ...
  #1 (permalink)  
Antiguo 13/01/2005, 15:27
Avatar de vpino  
Fecha de Ingreso: diciembre-2004
Ubicación: colombia
Mensajes: 265
Antigüedad: 20 años, 4 meses
Puntos: 0
Para Myakire:(crystal report)

Gente del foro: disculpen si desvio esta pregunta a Myakire, la razon, parece conocer mucho del tema y me puede colaborar. Si alguien mas me colabora, estare muy agradecido.

Llevo varios dias intentando ejecutar un informe hecho en crystal report 6.0, con la ayuda del foro he adelantado un poco, y lo digo asi porque me quedan algunos vacios y ademas no he logrado el objetivo(enlazar asp con crystal report 6.0).
apoyandome en los ejemplos he construido el siguiente codigo, el cual genera un error que no se a que se debe.

<%
response.expires = 0
rpttoview = "oc1"
showgrouptree = "1"
Session("report") = rpttoview

fullpathtorpt = "c:\prueba\oc1.rpt" 'ubicacion y nombre del reporte

las 2 lineas siguiente de codigo son para conectarme con la base de datos de sql, en la que me saca eror en la linea de: pathtomdb=con3.open"Driver={SQL Server};server........el error generardo es:Tipo de error:Error de compilación de Microsoft VBScript (0x800A0401),Se esperaba un final de instrucción programa.asp, línea 44, columna 20
donde linea 44 es de la que estamos hablando. Si inactivo esta linea (donde genera error) el programa muestra un pagina en blanco.



set con3= server.CreateObject("ADODB.Connection")
pathtomdb =con3.open"Driver={SQL Server};server=nombreservidor;UID=username;PWD=pas sword;DATABASE=nombre de la bd;"

If Not IsObject ( Session ("oApp")) Then
Set Session ("oApp") = Server.CreateObject("Crystal.CRPE.Application")
End If

Set oGlobalOptions = Session ("oApp").Options
oGlobalOptions.MorePrintEngineErrorMessages = 0

Set Session("oRpt") = Session("oApp").OpenReport(fullpathtorpt)

Set oRptOptions = Session("oRpt").Options
oRptOptions.MorePrintEngineErrorMessages = 0

Set oDB = session("oRpt").Database
For Each oDBTable In oDB.Tables
DBTable.Location = pathtomdb
Next

Session("oRpt").ReadRecords
Set Session("oPageEngine") = Session("oRpt").PageEngine
%>


te agradezco enormemente si analizas el codigo y me indicas la accion a seguir.
  #2 (permalink)  
Antiguo 14/01/2005, 08:40
Avatar de Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 23 años, 3 meses
Puntos: 146
El error es claro: "Se esperaba un final de instrucción", tienes una asignación mal hecha.
Cita:
pathtomdb =con3.open"Driver={SQL Server};server=nombreservidor;UID=username;PWD=pas sword;DATABASE=nombre de la bd;"
Deberia ser:
Cita:
pathtomdb ="Driver={SQL Server};server=nombreservidor;UID=username;PWD=pas sword;DATABASE=nombre de la bd;"
con3.open pathtomdb
  #3 (permalink)  
Antiguo 14/01/2005, 08:51
Avatar de Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 23 años, 3 meses
Puntos: 146
Mira, te paso un programa "report.asp" bastante comentado y solo ligeramente modificado . Funciona bien. Recuerda, no grabes el Reporte con Datos para que se actualice cada vez que lo invoques.

Código:
<%@ LANGUAGE="VBSCRIPT" %>
<title>Crystal Reports ASP Example - Changing a Formula Field value (Este es el ejemplo que modifiqué, los ejemplos los puedes bajar de la Web de Seagate)</title>
<%
'=============================================================================
' WORKING WITH THE REPORT DESIGNER COMPONENT AND ASP TO CHANGE A FORMULA FIELD
'=============================================================================                                                             
' CONCEPT

'   Once we have created the report object (oRpt), we can then 
'   gain access to such things the "Formula Fields" collection 
'   contained in  that report.  This is done through the 
'   FormulaFields collection.  
'   Since it is a collection, to gain access to a specific item 
'   in the collection, we use its index (1 based).  Once we can 
'   refer to a particular formula in the collection, we can modify
'   its value.                                                           
'                                                                     
'  ALWAYS REQUIRED STEPS (contained in AlwaysRequiredSteps.asp)
'   - create the application object                                
'   - create the report object                                     
'   - open the report                                              
'
'  MORE ALWAYS REQUIRED STEPS (contained in MoreRequiredSteps.asp)
'   - retreive the records                                         
'   - create the page engine 
'
'  DISPLAY THE REPORT
'   - display the report using a smart viewer
'==================================================================

'==================================================================
' ALWAYS REQUIRED STEPS
'
' Include the file AlwaysRequiredSteps.asp which contains the code    
' for steps:
'   - create the application object
'   - create the report object
'   - open the report
'==================================================================
%>                                                                     

<%
   ReportName = "PedidoCompra.rpt"

'This line creates a string variable called reportname that we will use to pass
'the Crystal Report filename (.rpt file) to the OpenReport method.
'To re-use this code for your application you would change the name of the report
'so as to reference your report file.

%>

<!-- #include file="AlwaysRequiredSteps.asp" -->                       

<%
'==================================================================
' If it is easier to understand, simply delete the line above, and    
' replace it with the entire contents of the file                     
' AlwaysRequiredSteps.asp                                             
'==================================================================


'==================================================================
' WORKING WITH SETLOGONINFO
'
' The datasource here is called "Automation".  It is a System 
' Datasource, and points to the "pubs" database, which is installed
' with SQL Server. You will also need to change your user id and
' password.

userid = "usuario"
password = "password"
(User/Password con que te conectas al SQLServer desde Crystal)

session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False

Set mainReportTableCollection = Session("oRpt").Database.Tables
For Each Table in mainReportTableCollection
     Table.SetLogonInfo "1.1.1.1", "NomBD", CStr(Userid), CStr(Password)
(Parametros de la cadena de conexión)
Next

'==================================================================

'==================================================================
' WORK WITH FORMULAS
'==================================================================
'   a. create a session varuable

Set FormulaFieldCollection = Session("oRpt").formulafields            

'   b. create the session variable, in this case oFFC, and point
'      it to the collection of formulas in the report 
'      (FormulaFieldCollection)   
                                                                     
set session("oFFC") = FormulaFieldCollection                          
                                                                   
'   c. point that session variable to a specific index in the       
'      collection                                                   
                                                                      

session("oFFC").Item(10).text = "'"&request.form("numpedido")&"'"						 'aNumPedido
 
(Ejemplo de envío de un parámetro/formula al informe. Recuerda que la el número de parámetro/formula es asignado por Crystal conforme los vas colocando)
'==================================================================



'==================================================================
'
'  MORE ALWAYS REQUIRED STEPS
'   - retreive the records                                         
'   - create the page engine                                       
'   - create the smart viewer and point it to rptserver.asp
'
'==================================================================
%>

<!-- #include file="MoreRequiredSteps.asp" -->

<%
'Response.Write("Error returned: " & err.number & " meaning: " & Err.Description) 
'==================================================================
' If it is easier to understand, simply delete the line above, and    
' replace it with the entire contents of the file                     
' MoreRequiredSteps.asp                                             
'==================================================================

' INSTANTIATE THE REPORT VIEWER
'
'When using the Crystal Reports in an ASP environment, we use
'the same page-on-demand Report Viewers used with the Crystal Web Component Server.
'There are six Report Viewers:
'
'1.  Report Viewer for ActiveX
'2.  Report Viewer for Java using Browser JVM
'3.  Report Viewer for Standard HTML with Frames
'4.  Report Viewer for Standard HTML
'5.  Report Viewer for Java Using Java Plugin
'6.  Report Viewer for Netscape Plug-in (ActiveX)
'
'The Report Viewer that you use will based on the browser's display capablities.
'For Example, you would not want to instantiate one of the Java viewers if the browser
'did not support Java applets.  For purposes on this demo, we have chosen to
'define a viewer.  You can through code determine the support capabilities of
'the requesting browser.  However that functionality is inherent in the Crystal
'Reports RDC and is beyond the scope of this demonstration app.
'
'We have chosen to leverage the server side include functionality of ASP
'for simplicity sake.  So you can use the SmartViewer*.asp files to instantiate
'the smart viewer that you wish to send to the browser.  Simply replace the line
'below with the Smart Viewer asp file you wish to use.
'
'The choices are SmartViewerActiveX.asp, SmartViewerJava.asp, JavaPluginViewer.asp,
'ActiveXPluginViewer.asp. SmartViewerHTMLFrame.asp, and SmartViewerHTMLPAge.asp.
'Note that to use this include you must have the appropriate .asp file in the 
'same virtual directory as the main ASP page.
'
'*NOTE* For SmartViewerHTMLFrame and SmartViewerHTMLPage, you must also have
'the files framepage.asp and toolbar.asp in your virtual directory.


'=============================================================================
'  DISPLAY THE REPORT
'   - display the report using a smart viewer
' 
' Include one of the Smart Viewers.
'  - Report Viewer for ActiveX			=   SmartViewerActiveX.asp
'  - Report Viewer for Java using Browser JVM	=   SmartViewerJAVA.asp
'  - Report Viewer for Standard HTML		=   SmartViewerHTMLPage.asp
'  - Report Viewer for Standard HTML w/ Frames	=   SmartViewerHTMLFrame.asp
'  - Report Viewer for Java Using Java Plugin	=   JavaPluginViewer.asp
'  - Report Viewer for Netscape Plug-in		=   ActiveXPluginViewer.asp
'=============================================================================
%>
 
                                                                     
<!-- #include file="SmartViewerActiveX.asp" -->                    

<%      
                                                                
'==================================================================
' If it easier for you to conceptualize this code by seeing it all
' contained in a single file, simply delete the line above, and
' replace it with the entire contents of the file being included.
'==================================================================

%>
  #4 (permalink)  
Antiguo 14/01/2005, 09:00
Avatar de vpino  
Fecha de Ingreso: diciembre-2004
Ubicación: colombia
Mensajes: 265
Antigüedad: 20 años, 4 meses
Puntos: 0
Myakire: mil gracias por ayudarme, probare el codigo que me envias(report.asp) y te comento luego los resultado, ya que corregi las lineas enviadas anteriormente y el programa no genera error, pero da como resultado una pagina en blanco. nuevamente te agradezco.
  #5 (permalink)  
Antiguo 14/01/2005, 11:40
Avatar de vpino  
Fecha de Ingreso: diciembre-2004
Ubicación: colombia
Mensajes: 265
Antigüedad: 20 años, 4 meses
Puntos: 0
Hola Carlos: Hice las pruebas y obtuve esto:

El objeto no acepta esta propiedad o método: 'session(...).MorePrintEngineErrorMessages'
/prueba/reporte1.asp, línea 74

si dejo como comentario la linea en la que se genera el error, saca error en esta otra instruccion

El objeto no acepta esta propiedad o método: 'session(...).EnableParameterPrompting'
/prueba/reporte1.asp, línea 75

al dejar la linea 75 como comentario se ejecuta el programa mostrando solo un recuadro en blanco y una linea

el codigo es elsiguiente:

<%@ LANGUAGE="VBSCRIPT" %>
<title>Crystal Reports ASP Example - Changing a Formula Field value (Este es el ejemplo que modifiqué, los ejemplos los puedes bajar de la Web de Seagate)</title>
<%
'================================================= ============================
' WORKING WITH THE REPORT DESIGNER COMPONENT AND ASP TO CHANGE A FORMULA FIELD
'================================================= ============================
' CONCEPT

' Once we have created the report object (oRpt), we can then
' gain access to such things the "Formula Fields" collection
' contained in that report. This is done through the
' FormulaFields collection.
' Since it is a collection, to gain access to a specific item
' in the collection, we use its index (1 based). Once we can
' refer to a particular formula in the collection, we can modify
' its value.
'
' ALWAYS REQUIRED STEPS (contained in AlwaysRequiredSteps.asp)
' - create the application object
' - create the report object
' - open the report
'
' MORE ALWAYS REQUIRED STEPS (contained in MoreRequiredSteps.asp)
' - retreive the records
' - create the page engine
'
' DISPLAY THE REPORT
' - display the report using a smart viewer
'================================================= =================

'================================================= =================
' ALWAYS REQUIRED STEPS
'
' Include the file AlwaysRequiredSteps.asp which contains the code
' for steps:
' - create the application object
' - create the report object
' - open the report
'================================================= =================
%>

<%
ReportName = "oc1.rpt"

'This line creates a string variable called reportname that we will use to pass
'the Crystal Report filename (.rpt file) to the OpenReport method.
'To re-use this code for your application you would change the name of the report
'so as to reference your report file.

%>

<!-- #include file="AlwaysRequiredSteps.asp" -->

<%
'================================================= =================
' If it is easier to understand, simply delete the line above, and
' replace it with the entire contents of the file
' AlwaysRequiredSteps.asp
'================================================= =================


'================================================= =================
' WORKING WITH SETLOGONINFO
'
' The datasource here is called "Automation". It is a System
' Datasource, and points to the "pubs" database, which is installed
' with SQL Server. You will also need to change your user id and
' password.

userid = "sa"
password = "t3arg"
'(User/Password con que te conectas al SQLServer desde Crystal)

'session("oRpt").MorePrintEngineErrorMessages = False
'session("oRpt").EnableParameterPrompting = False

Set mainReportTableCollection = Session("oRpt").Database.Tables
For Each Table in mainReportTableCollection
Table.SetLogonInfo "1.1.1.1", "NomBD", CStr(Userid), CStr(Password)
'(Parametros de la cadena de conexión)
Next

'================================================= =================

'================================================= =================
' WORK WITH FORMULAS
'================================================= =================
' a. create a session varuable

Set FormulaFieldCollection = Session("oRpt").formulafields

' b. create the session variable, in this case oFFC, and point
' it to the collection of formulas in the report
' (FormulaFieldCollection)

set session("oFFC") = FormulaFieldCollection

' c. point that session variable to a specific index in the
' collection


'session("oFFC").Item(10).text = "'"&request.form("numpedido")&"'" 'aNumPedido

'(Ejemplo de envío de un parámetro/formula al informe. Recuerda que la el número de parámetro/formula es asignado por Crystal conforme los vas colocando)
'================================================= =================



'================================================= =================
'
' MORE ALWAYS REQUIRED STEPS
' - retreive the records
' - create the page engine
' - create the smart viewer and point it to rptserver.asp
'
'================================================= =================
%>

<!-- #include file="MoreRequiredSteps.asp" -->

<%
'Response.Write("Error returned: " & err.number & " meaning: " & Err.Description)
'================================================= =================
' If it is easier to understand, simply delete the line above, and
' replace it with the entire contents of the file
' MoreRequiredSteps.asp
'================================================= =================

' INSTANTIATE THE REPORT VIEWER
'
'When using the Crystal Reports in an ASP environment, we use
'the same page-on-demand Report Viewers used with the Crystal Web Component Server.
'There are six Report Viewers:
'
'1. Report Viewer for ActiveX
'2. Report Viewer for Java using Browser JVM
'3. Report Viewer for Standard HTML with Frames
'4. Report Viewer for Standard HTML
'5. Report Viewer for Java Using Java Plugin
'6. Report Viewer for Netscape Plug-in (ActiveX)
'
'The Report Viewer that you use will based on the browser's display capablities.
'For Example, you would not want to instantiate one of the Java viewers if the browser
'did not support Java applets. For purposes on this demo, we have chosen to
'define a viewer. You can through code determine the support capabilities of
'the requesting browser. However that functionality is inherent in the Crystal
'Reports RDC and is beyond the scope of this demonstration app.
'
'We have chosen to leverage the server side include functionality of ASP
'for simplicity sake. So you can use the SmartViewer*.asp files to instantiate
'the smart viewer that you wish to send to the browser. Simply replace the line
'below with the Smart Viewer asp file you wish to use.
'
'The choices are SmartViewerActiveX.asp, SmartViewerJava.asp, JavaPluginViewer.asp,
'ActiveXPluginViewer.asp. SmartViewerHTMLFrame.asp, and SmartViewerHTMLPAge.asp.
'Note that to use this include you must have the appropriate .asp file in the
'same virtual directory as the main ASP page.
'
'*NOTE* For SmartViewerHTMLFrame and SmartViewerHTMLPage, you must also have
'the files framepage.asp and toolbar.asp in your virtual directory.


'================================================= ============================
' DISPLAY THE REPORT
' - display the report using a smart viewer
'
' Include one of the Smart Viewers.
' - Report Viewer for ActiveX = SmartViewerActiveX.asp
' - Report Viewer for Java using Browser JVM = SmartViewerJAVA.asp
' - Report Viewer for Standard HTML = SmartViewerHTMLPage.asp
' - Report Viewer for Standard HTML w/ Frames = SmartViewerHTMLFrame.asp
' - Report Viewer for Java Using Java Plugin = JavaPluginViewer.asp
' - Report Viewer for Netscape Plug-in = ActiveXPluginViewer.asp
'================================================= ============================
%>


<!-- #include file="SmartViewerActiveX.asp" -->

<%

'================================================= =================
' If it easier for you to conceptualize this code by seeing it all
' contained in a single file, simply delete the line above, and
' replace it with the entire contents of the file being included.
'================================================= =================

%>
  #6 (permalink)  
Antiguo 14/01/2005, 12:01
Avatar de Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 23 años, 3 meses
Puntos: 146
¿Tienes los includes a los que hace referencia el ejemplo?

Sugerencia: Tus códigos enciérralos entre [ CODE ] y [ /CODE ] (sin espacios) para que los post no estén tan largos

Última edición por Myakire; 14/01/2005 a las 12:02
  #7 (permalink)  
Antiguo 14/01/2005, 12:18
Avatar de vpino  
Fecha de Ingreso: diciembre-2004
Ubicación: colombia
Mensajes: 265
Antigüedad: 20 años, 4 meses
Puntos: 0
carlos: efectivamente tengo los includes a los que hace referencia el ejemplo sin ellos se generaba error en esas lineas correpondientes (los busque y los coloque en el mismo directorio). Gracias por ayudarme
  #8 (permalink)  
Antiguo 14/01/2005, 12:21
Avatar de vpino  
Fecha de Ingreso: diciembre-2004
Ubicación: colombia
Mensajes: 265
Antigüedad: 20 años, 4 meses
Puntos: 0
ah! se me olvido preguntar a cerca de la sugerencia, soy nuevo en esto no compredi bien la sugerencia.
  #9 (permalink)  
Antiguo 30/08/2005, 09:59
 
Fecha de Ingreso: julio-2005
Mensajes: 4
Antigüedad: 19 años, 9 meses
Puntos: 0
este codigo estoy usando en asp para poder enviar parametros al crystal,

set session("ParamCollection") = Session("oRpt").Parameterfields
set Param1 = session("ParamCollection").Item(1)
Set Param2 = session("ParamCollection").Item(2)
Set Param3 = session("ParamCollection").Item(3)

Call Param1.SetCurrentValue (CDbl(vreg), 7)
Call Param2.SetCurrentValue (CDbl(vtam), 7)
Call Param3.SetCurrentValue (CDbl(vaaa), 7)

necesito enviale 3 parametros se los envio funciona pero en el call param1..... al final no recuerdo para q son los numeros y ademas lo entiendo como si estuvieran pasando los parametros por una sola puerta y deberia reclamarme pero no lo hace me podrias explicar por fa
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 09:51.