0

嗨,我使用数据集创建带有水晶报表的报表

http://upload7.ir/images/59709775438148913038.jpg

我的负载报告代码:

导入 System.Data.SqlClient

公共类 varede_report

Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
    Dim rpt As New CrystalReport1
    Dim myconnection As SqlConnection
    Dim mycommand As New SqlCommand
    Dim myda As New SqlDataAdapter
    Dim myds As New rt_DataSet
    Try
        myconnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\khatam.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
        mycommand.Connection = myconnection
        mycommand.CommandText = "select * from letter1"
        mycommand.CommandType = CommandType.Text
        myda.SelectCommand = mycommand
        myda.Fill(myds, "letter1")
        rpt.SetDataSource(myds)
        CrystalReportViewer1.ReportSource = rpt
    Catch ex As Exception
        'MessageBox.Show(Excep.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try

End Sub

Private Sub varede_report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

结束类

但是当我运行这个应用程序时,不要在报告中显示数据集中的表格记录,请帮助我!!!

4

1 回答 1

0

我在 VB 上的速度不是 100%,但是您的代码没有显示任何地方来实际加载报告。在 C# 中你会有类似的东西

protected void Page_Load(object sender, EventArgs e)
{
ReportDocument reportdocument = new ReportDocument();
reportdocument.Load(Server.MapPath("CrystalReport.rpt"));
reportdocument.SetDatabaseLogon("username","password","SureshDasari","MySampleDB");
CrystalReportViewer1.ReportSource = reportdocument;
} 

其中行reportdocument.Load(Server.MapPath("CrystalReport.rpt"));指定报告。我在你的代码中没有看到。所以把类似的东西rpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")放在你的 CrystalReportViewer1_Load 中,看看它是否有效。

于 2013-11-04T14:04:40.610 回答