该报告没有表格
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
此代码显示错误“报告没有表格”
我想实用地使用 Access 2003 数据库显示水晶报表。在项目中添加空白报告并尝试填充它的 DataSet 对象,上面代码中的任何建议或更正。
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
This code show error "Report has no tables"
i want to show crystal report using Access 2003 Database pragmatically. blank report is added in project and trying to fill it DataSet object, any suggestion or correction in above code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您将 DataAdapter 的值添加到数据集
objDatasetExpence
中名为"expences"
的表中,并且您没有将报表对象的数据源指向数据集中的数据表。按如下方式更改代码并重试当您将数据源分配给报表的数据库字段时,将会出现相同的错误“报表没有表”。请参阅下图,还请参阅下一张图片,其中我没有为报告分配数据库字段,并且出现相同的错误
Ya, you added the values of DataAdapter to a table in the dataset
objDatasetExpence
with name"expences"
and you are not pointing the datasource of report object to the datatable inside the dataset. Change your code as follows and try againWhen you dint assign a Datasource to the Database Fields of the Report the same error will come "The report has no tables". See the below Figure and also see the next image where I dint assigned a database fields to the report and the same error I got