The report has no tables
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 repor开发者_StackOverflow社区t 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.
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 got
精彩评论