zoukankan      html  css  js  c++  java
  • crystal report (asp调用水晶报表实例)

    <%@ LANGUAGE="VBSCRIPT" %>
    <%
    Response.Expires = -1
    Response.AddHeader "Pragma", "no-cache"
    Response.AddHeader "cache-control", "no-store"
    'response.write("<script language=javascript>alert('"&JOB_ID&"')</script>")
    reportname = Server.MapPath(Request("url"))'获取报表的所在的路径

    If Not IsObject(session("oApp")) Then '返回 Boolean 值指明表达式是否引用了有效的 Automation 对象。
    'alert("fds");
     Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.9")
     session("oApp").LogOnServer "pdssql.dll", "127.0.0.1", "database", " user", "123"
    End If

    If IsObject(session("oRpt")) then
     Set session("oRpt") = nothing
    End if

    Set session("oRpt") = session("oApp").OpenReport(reportname, 1)

    Set mainReportTableCollection = Session("oRpt").Database.Tables

    For Each Table in mainReportTableCollection
           Table.SetLogonInfo "127.0.0.1","shat", "shat_user", "tahs_54321"
    Next

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

    session("oRpt").DiscardSavedData
    session("oRpt").RecordSelectionFormula = GetDecodeStr(Request("sf"))
    'response.write "sf=" & GetDecodeStr(Request("sf"))
    'Set Value for Parameter Field
    strParams = Request("params")
    arrParams = split(strParams, ",")
    set oParamCollection = Session("oRpt").Parameterfields
    for i =  1 to oParamCollection.Count
     if i <= (UBound(arrParams)+1) then
      set oParam = oParamCollection.Item(i)
      oParam.SetCurrentValue GetDecodeStr(CStr(arrParams(i-1))), 12
     end if
    next

    On Error Resume Next
    session("oRpt").ReadRecords
    If Err.Number <> 0 Then
     Response.Write err.description
     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                                                               
    %>

    <HTML>
    <HEAD>
    <TITLE>Report Viewer</TITLE>
    <BASE target="_self">
    <SCRIPT language="JScript.Encode" runat="server" src="_xForm_Library/basic.js"></SCRIPT>
    </HEAD>
    <BODY BGCOLOR=#c6c6c6 LANGUAGE=VBScript ONLOAD="Page_Initialize" style="border-style: none" bottomMargin=0 leftMargin=0 topMargin=0 rightMargin=0 scroll=no>

    <OBJECT id=CRViewer style="HEIGHT: 100%"
     codebase="/viewer/activeXViewer/activexviewer.cab#Version=9.2.1.175" height="100%"
     width="100%" classid=CLSID:2DEF4530-8CE6-41C9-84B6-A54536C90213>

    </OBJECT>

    <SCRIPT LANGUAGE="VBScript">
    <!--
    Sub Page_Initialize
     On Error Resume Next
     Dim webBroker
     Set webBroker = CreateObject("WebReportBroker9.WebReportBroker")
     if ScriptEngineMajorVersion < 2 then
      window.alert "IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site."
      CRViewer.ReportName = "rptserver.asp"
     else
      Dim webSource
      Set webSource = CreateObject("WebReportSource9.WebReportSource")
      webSource.ReportSource = webBroker
      webSource.URL = "rptserver.asp"
      webSource.PromptOnRefresh = True
      CRViewer.ReportSource = webSource
     end if
     CRViewer.ViewReport
    End Sub
    -->
    </SCRIPT>

    </BODY>
    </HTML>

  • 相关阅读:
    js 获得多个同name 的input输入框的值
    推荐系统
    异常检测
    降维——PCA主成分分析
    无监督学习——降维
    无监督学习——K-means聚类
    支持向量机——内核
    支持向量机背后的数学
    支持向量机——Large Margin Classifier
    支持向量机
  • 原文地址:https://www.cnblogs.com/winner/p/357245.html
Copyright © 2011-2022 走看看