asp.net调用已存在的水晶报表 5

已用CrystalReports2008做好了一个水晶报表,放在了硬盘的某个目录里,想用asp.netC#程序调用显示这个报表,如何实现?是初学者麻烦代码详细些... 已用CrystalReports2008做好了一个水晶报表,放在了硬盘的某个目录里,想用asp.net C #程序调用显示这个报表,如何实现?是初学者麻烦代码详细些 展开
 我来答
chuxue1342
2011-03-10 · TA获得超过747个赞
知道小有建树答主
回答量:414
采纳率:0%
帮助的人:400万
展开全部
我很久之前做了一个动态调用水晶报表的代码,VB.net写的:
mports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Web
Imports System.Web.UI
Imports CrystalDecisions.Reporting
Imports CrystalDecisions.ReportSource
Imports System.IO
Partial Class productreport
Inherits System.Web.UI.Page
Private ht As Hashtable
Private mysql As database
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim ReportDoc As New ReportDocument()
Dim logonInfo As New TableLogOnInfo
Dim table As Table
ReportDoc.Load(Server.MapPath("Crproduct.rpt"))
For Each table In ReportDoc.Database.Tables
logonInfo = table.LogOnInfo
With logonInfo.ConnectionInfo
.ServerName = "mis"
.DatabaseName = "sincehome"
.UserID = "sa"
.Password = "sa"
End With
table.ApplyLogOnInfo(logonInfo)
Next table
CrystalReportViewer1.ReportSource = ReportDoc
End If
End Sub
Protected Sub searchbt_click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim dt As DataTable = New DataTable
Dim sql As String = "select * from product where type='" & Me.Ttype.Text & "'"
mysql = New database
dt = mysql.get_table(sql).Tables(0)
Me.CrySource.ReportDocument.Load(Server.MapPath("Crproduct.rpt"))
Me.CrySource.ReportDocument.SetDataSource(dt)
Me.CrySource.DataBind()
Me.CrystalReportViewer1.ReportSource = Me.CrySource
End Sub
End Class
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式