我使用数据集
创建一个包含水晶报表的报表http://upload7.ir/images/59709775438148913038.jpg
我的加载报告代码:
Imports System.Data.SqlClient
Public Class 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 :(得分:0)
我不是百分之百地加速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")
之类的内容,看看是否有效。