2013-11-04 81 views
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 

末级

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

回答

0

我不是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")的东西,看看是否有效。

+0

Dim rpt As New CrystalReport1 – user2952689

+0

将变量rpt声明为Crystal Report,但它没有指定报告的位置或指示程序加载报告。 –