Vb.net 不在crystal report with dataset中显示记录数据

Vb.net 不在crystal report with dataset中显示记录数据,vb.net,crystal-reports,dataset,report,Vb.net,Crystal Reports,Dataset,Report,您好,我使用数据集使用crystal report创建了一个报告 我的加载报告代码: 导入System.Data.SqlClient 公共类varede_报告 Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load Dim rpt As New CrystalReport1

您好,我使用数据集使用crystal report创建了一个报告

我的加载报告代码:

导入System.Data.SqlClient

公共类varede_报告

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上的速度不是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”)指定报告。我在你的代码中看不到这一点。因此,在CrystalReportViewer1中加载类似于
rpt.Load(“在此处放置CrystalReport路径\CrystalReport1.rpt”)
的内容,然后查看是否有效。

将rpt设置为新的CrystalReport1,它将变量rpt声明为CrystalReport,但它不会指定报告的位置或告诉程序加载报告。