【问题标题】:dont show record data in crystal report with dataset不要在带有数据集的水晶报表中显示记录数据
【发布时间】:2013-11-15 03:45:03
【问题描述】:

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

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

结束类

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

【问题讨论】:

    标签: vb.net crystal-reports dataset report


    【解决方案1】:

    我没有 100% 了解 VB,但您的代码没有显示任何地方来实际加载报告。在 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")); 行指定报告。我在你的代码中没有看到。因此,在您的 CrystalReportViewer1_Load 中添加 rpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt") 之类的内容,看看是否可行。

    【讨论】:

    • 将 rpt 变暗为新 CrystalReport1
    • 将变量rpt声明为水晶报表,但没有指定报表的位置,也没有告诉程序加载报表。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-11
    • 2013-08-28
    相关资源
    最近更新 更多