0
votes

am new in crystal report, here wana to add 2 datatables in the crstal report'

Private Sub btbPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btbPrint.Click

    '
    Dim ds As New DataSet1
    Dim t As DataTable = GetInvoice(txtBillNo.Text)
    Dim dt As DataTable = GetDCDetails(t.Rows(0).Item("DcID"))
    Dim objRpt As New CrystalReport1
    Dim adopter As New SqlDataAdapter
    '

'''Here i wana to add the datatable dt in the datasourece''''

    objRpt.SetDataSource(t)
    CrystalReportViewer1.ReportSource = objRpt
    CrystalReportViewer1.Refresh()
    '
End Sub
2

2 Answers

0
votes

I dont think you can give the report multiple dataTables as the dataSource, the best option would be to join the tables (invoice and its details in sql) and put that into a dataTable and set that as the dataSource.

0
votes

You can use something like this

'Set datasource for each table
objRpt.Database.Tables("table1").SetDataSource(t)
objRpt.Database.Tables("table2").SetDataSource(dt)

CrystalReportViewer1.ReportSource = objRpt
CrystalReportViewer1.Refresh()

Where "table1" and "table2" are database tables in the report