该报告没有表格

发布于 2024-12-04 06:46:06 字数 1174 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋风の叶未落 2024-12-11 06:46:06

是的,您将 DataAdapter 的值添加到数据集 objDatasetExpence 中名为 "expences" 的表中,并且您没有将报表对象的数据源指向数据集中的数据表。按如下方式更改代码并重试

objRptExpence.SetDataSource(objDatasetExpence.Tables(0)) 
          (or)
objRptExpence.SetDataSource(objDatasetExpence.Tables("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 again

objRptExpence.SetDataSource(objDatasetExpence.Tables(0)) 
          (or)
objRptExpence.SetDataSource(objDatasetExpence.Tables("expences")) 

When 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 gotSetting Database FieldsActuall Error

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文