Me.BindingSource1.DataSource = DataTable1TableAdapter1
Dim rds As New ReportDataSource("DataSet2", Me.BindingSource1)
Me.ReportViewer1.LocalReport.ReportPath = "D:\Test.rdlc"
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(rds)
Me.ReportViewer1.RefreshReport()
ดูจากในรูป ภาพบนจะเป็นข้อมูลใน Report Builder ส่วนภาพล่างจะ run ใน from vs มันไม่ขึ้นอ่ะค่ะ
Tag : .NET, Ms SQL Server 2012, VS 2012 (.NET 4.x)
'Me.BindingSource1.DataSource = DataTable1TableAdapter1
Dim ds As New DataSet() With {.DataSetName = "DataSet2"}
Dim dtTempXXX As New DataTable() With {.TableName = "tmpXXX"}
dtTempXXX.Columns.Add("stkCode", GetType(String))
dtTempXXX.Columns.Add("stkName", GetType(String))
dtTempXXX.Rows.Add(New Object() {"0031", "erectile dysfunction"})
dtTempXXX.Rows.Add(New Object() {"0032", "Viagra"})
ds.Tables.Add(dtTempXXX)
'Dim rds As New ReportDataSource("DataSet2", Me.BindingSource1)
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet2", ds.Tables("dtTempXXX"))) 'it is case sensitive
Me.ReportViewer1.LocalReport.ReportPath = "D:\Test.rdlc"
Me.ReportViewer1.RefreshReport()