用Crystal Report RunTime的Application对象的NewReport方法。

解决方案 »

  1.   

    对了,Crystal Report不是带有这方面的例子吗?
      

  2.   

    你说的“Crystal Report RunTime的Application对象”是Crystal.CRPE.Application(ASP中的progID)吗?它只有OpenReport方法。至于这方面的例子我没找到,找到的都是报表已经建立好的。
      

  3.   

    我用的是Developer版,有的。不是Crystal.CRPE.Application。
    是这个:Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")
      

  4.   

    tonyjoule(寒星㊣),谢了,我的不是Developer版的,所以没有。另外想问个问题,从哪里能知道那些组件的progID呢,如CrystalRuntime.Application
      

  5.   

    <%@ LANGUAGE="VBSCRIPT" %><%
    Set oConn = Server.CreateObject("ADODB.Connection")oConn.Open("Xtreme Sample Database")set session("oRs") = Server.CreateObject("ADODB.Recordset")session("oRs").ActiveConnection = oConnsession("oRs").Open "SELECT [Product ID], [Product Name] FROM Product"reportname = "ADORecordset.rpt"If Not IsObject (session("oApp")) Then                              
    Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")
    End If                                                                Path = Request.ServerVariables("PATH_TRANSLATED")                     
    While (Right(Path, 1) <> "\" And Len(Path) <> 0)                      
    iLen = Len(Path) - 1                                                  
    Path = Left(Path, iLen)                                               
    Wend                                                                  
    If IsObject(session("oRpt")) then
    Set session("oRpt") = nothing
    End ifSet session("oRpt") = session("oApp").OpenReport(path & reportname, 1)session("oRpt").MorePrintEngineErrorMessages = False
    session("oRpt").EnableParameterPrompting = Falsesession("oRpt").DiscardSavedData
    set Database = session("oRpt").Databaseset Tables = Database.Tablesset Table1 = Tables.Item(1)Table1.SetPrivateData 3, session("oRs") 'The "SetPrivateData" line tells the report that it datasource is now the recordset
    'Now the report will display the data contained in the session("oRs") record set.
    'If your report contained a subreport that was based off this or a different reordset
    'you must follow the same steps above only referencing the subreport object.
    '
    '
    '====================================================================================
    ' Retrieve the Records and Create the "Page on Demand" Engine Object
    '====================================================================================On Error Resume Next                                                  
    session("oRpt").ReadRecords                                           
    If Err.Number <> 0 Then                                               
      Response.Write "An Error has occured on the server in attempting to access the data source"
    Else  If IsObject(session("oPageEngine")) Then                              
       set session("oPageEngine") = nothing
      End If
    set session("oPageEngine") = session("oRpt").PageEngine
    End If                                                                ' INSTANTIATE THE CRYSTAL REPORTS SMART VIEWER
    '
    'When using the Crystal Reports automation server in an ASP environment, we use
    'the same page on demand "Smart Viewers" used with the Crystal Web Report Server.
    'The are four Crystal Reports Smart Viewers:
    '
    '1.  ActiveX Smart Viewer
    '2.  Java Smart Viewer
    '3.  HTML Frame Smart Viewer
    '4.  HTML Page Smart Viewer
    '
    'The Smart Viewer that you use will based on the browser's display capablities.
    'For Example, you would not want to instantiate the Java viewer 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 automation server 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, SmartViewerJave.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.viewer = Request.Form("Viewer")'This line collects the value passed for the viewer to be used, and stores
    'it in the "viewer" variable.If cstr(viewer) = "ActiveX" then
    %>
    <!-- #include file="SmartViewerActiveX.asp" -->
    <%
    ElseIf cstr(viewer) = "Netscape Plug-in" then
    %>
    <!-- #include file="ActiveXPluginViewer.asp" -->
    <%
    ElseIf cstr(viewer) = "Java using Browser JVM" then
    %>
    <!-- #include file="SmartViewerJava.asp" -->
    <%
    ElseIf cstr(viewer) = "Java using Java Plug-in" then
    %>
    <!-- #include file="JavaPluginViewer.asp" -->
    <%
    ElseIf cstr(viewer) = "HTML Frame" then
    Response.Redirect("htmstart.asp")
    Else
    Response.Redirect("rptserver.asp")
    End If
    'The above If/Then/Else structure is designed to test the value of the "viewer" varaible
    'and based on that value, send down the appropriate Crystal Smart Viewer.
    %>