I follow the article of the following link.
http://vb.net-informations.com/crystal-report/vb.net_crystal_report_subreport.htm
But I get an error as the following.
http://i.imgur.com/4MGeOsQ.jpg?1
I followed the steps to linking the the "id" field but it gave me the error.
Here is the code. (database.show(sql) is a function that return a datatable.)
Dim sql As String = "select oid as 'id', time as 'InvoiceDate', invoiceto as 'InvoiceNo', depost2 as 'Discount' from `order` limit 0,3"
Dim dtinv As DataTable = database.show(sql)
sql = "select oid as 'id', productbarcode as 'ItemCode', p.pname as 'ItemName', p.cost as 'Cost', p.dprice as 'UnitPrice', qty as 'Qty', extendedprice as 'TotalAmount' from suborder o left join `product` p on (o.productbarcode = p.pcode) where oid in ("
Dim o As String = ""
For Each row As DataRow In dtinv.Rows
If o.Length > 0 Then
o &= " ," & row.Item("id")
Else
o &= row.Item("id")
End If
Next
sql &= o & ")"
Dim dt As DataTable = database.show(sql)
Dim crystalReport As ReportDocument = New ReportDocument()
crystalReport.Load("./SalesOrderReport.rpt")
crystalReport.SetDataSource(dtinv)
crystalReport.Subreports(0).SetDataSource(dt)
CrystalReportViewer1.ReportSource = crystalReport
The "dtinv" table should be as the following.
id InvoiceDate InvoiceNo Discount
35 2014-12-08 14:36:16 IAN000035 0
36 2014-12-08 14:44:13 IAN000036 0
37 2014-12-08 14:48:35 IAN000037 0
The "dt" table should be as the following.
id ItemCode ItemName Cost UnitPrice Qty TotalAmount
35 108 Pureness 100 Placenta Mask Sheet Strengthening Ski... 50 100 1 100.00
35 3 Pure Water Baobab Moist Cream 50 100 1 100.00
36 3 Pure Water Baobab Moist Cream 50 100 1 100.00
37 5 Aloe Moistfull Soothing Lotion 50 100 1 100.00
Please help me and give me some advise to solve this problem. Thanks a lot.