2
Private Sub frmReportExpenses_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim objDatasetExpence As New dSetExpences // dataset object named as dSetExpences
Dim objRptExpence As New rptExpences // Crystal report object
Dim MyCommand As New OleDbCommand()
Dim MyConnection As OleDbConnection
Dim myDA As New OleDbDataAdapter()
Try
Dim connstring As String = "D:\HMSProjects\SMS\SMS\bin\Debug\"
MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + connstring + "msautoconfig.mdb;")
MyConnection.Open()
MyCommand.Connection = MyConnection
MyCommand.CommandText = "SELECT * FROM expences"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(objDatasetExpence, "expences")
objRptExpence.SetDataSource(objDatasetExpence) // error here (Report has no Table)
CrystalReportViewer1.ReportSource = objRptExpence
Catch ex As Exception
End Try
Me.WindowState = FormWindowState.Maximized
End Sub
End Class
此代碼顯示錯誤"Report has no tables"
我想實用地使用Access 2003數據庫顯示水晶報表。在項目中添加空白報告並試圖填充DataSet對象,以上代碼中的任何建議或更正。該報告沒有表
是我還修改了代碼,因爲您建議我,但它又顯示相同類型的錯誤雖然objRptExpence有一些費用表,但我在調試器模式下看到它 –
您是否可以傳遞您第二次修改的代碼。 –
myDA.Fill(objDatasetExpence,「expences」) objRptExpence.SetDataSource(objDatasetExpence.Tables(「expences」)) CrystalReportViewer1.ReportSource = objRptExpence –