Crystal报表未显示在网页中 [英] Crystal report is not displayed in the web page

查看:99
本文介绍了Crystal报表未显示在网页中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页是空白的,我的报告中没有显示数据,这里是代码:

导出的文件在那里,但为什么报告没有显示在网页上?



My web page is blank the data are not displayed in my report here is the code:
The exported file is there but why the report is not displayed in the web page???

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration


Public Class WebForm3
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim rptDoc As ReportDocument = New ReportDocument
        Dim ds As DataSet1 = New DataSet1
        Dim dt As DataTable = New DataTable
        ' Just set the name of data table
        dt.TableName = "Crystal Report Example"
        dt = getAllOrders
        'This function is located below this function
        ds.Tables(0).Merge(dt)
        ' Your .rpt file path will be below
        rptDoc.Load(Server.MapPath("CrystalReport4.rpt"))
        'set dataset to the report viewer.
        rptDoc.SetDataSource(ds)
        rptDoc.ExportToDisk(ExportFormatType.Excel, Server.MapPath("myExcelFile.xls"))
        CrystalReportViewer1.ReportSource = rptDoc


    End Sub

    Public Function getAllOrders() As DataTable
        'Connection string replace 'databaseservername' with your db server name
        Dim sqlCon As String = ("myConnectionString")
        Dim Con As SqlConnection = New SqlConnection(sqlCon)
        Dim cmd As SqlCommand = New SqlCommand
        Dim ds As DataSet = Nothing
        Dim adapter As SqlDataAdapter
        Try
            Con.Open()
            'Stored procedure calling. It is already in sample db.
            cmd.CommandText = "Select Top 23 X,Y From myTable"
            cmd.CommandType = CommandType.Text
            cmd.Connection = Con
            ds = New DataSet
            adapter = New SqlDataAdapter(cmd)
            adapter.Fill(ds, "Users")
        Catch ex As Exception
            Throw New Exception(ex.Message)
        Finally
            cmd.Dispose()
            If (Con.State <> ConnectionState.Closed) Then
                Con.Close()
            End If
        End Try
        Return ds.Tables(0)
    End Function

End Class

推荐答案

这篇关于Crystal报表未显示在网页中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆