Dateset中的数据无法加载至报表并显示出来,不知是何原因还请各位大虾请教!!!!
Dateset中的数据无法加载至报表并显示出来,以下是我的代码:(myReportDoc.SetDataSource(ds)中ds里是有数据的)
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myconnection As New SqlConnection("SERVER=Local;database=jiankong;uid=sa;pwd=")
Dim mycommand As SqlDataAdapter
Dim ds As DataSet = New 监控
Dim stringsql As String
stringsql = "select * from zidongjiankong where (occur_day> =('" + 开始日期 + "') and occur_day<=('" + 结束日期 + " ')) "
mycommand = New SqlDataAdapter(stringsql, myconnection)
Try
mycommand.Fill(ds, "jk")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Dim itest As Int32 = ds.Tables("jk").Rows.Count
Dim myReportDoc As New ReportDocument
Try
myReportDoc.Load(Application.StartupPath & "\监控日志.rpt")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
myReportDoc.SetDataSource(ds)
CrystalReportViewer2.ReportSource = myReportDoc
End Sub