how to create simple report

mary

Member
Joined
Aug 28, 2006
Messages
6
Programming Experience
Beginner
i have created a table dynamically and i have created a dataset for that table.

i want to view that table in report viewer. is it possible. i used the following code but iam not getting that data in reportviewer control.

VB.NET:
Me.ReportViewer1.RefreshReport() 
Try 
Dim table As New DataTable("reporting") 
Dim Row1, Row2, Row3 As DataRow 
Try 
Dim Name As DataColumn = New DataColumn("Name") 
'declaring a column named Name 
Name.DataType = System.Type.GetType("System.String") 
'setting the datatype for the column 
table.Columns.Add(Name) 
'adding the column to table 
Dim Product As DataColumn = New DataColumn("Product") 
Product.DataType = System.Type.GetType("System.String") 
table.Columns.Add(Product) 
Dim Location As DataColumn = New DataColumn("Location") 
Location.DataType = System.Type.GetType("System.String") 
table.Columns.Add(Location) 
Row1 = table.NewRow() 
'declaring a new row 
Row1.Item("Name") = "Reddy" 
'filling the row with values. Item property is used to set the field value. 
Row1.Item("Product") = "Notebook" 
'filling the row with values. adding a product 
Row1.Item("Location") = "Sydney" 
'filling the row with values. adding a location 
table.Rows.Add(Row1) 
'adding the completed row to the table 
Row2 = table.NewRow() 
Row2.Item("Name") = "Bella" 
Row2.Item("Product") = "Desktop" 
Row2.Item("Location") = "Adelaide" 
table.Rows.Add(Row2) 
Row3 = table.NewRow() 
Row3.Item("Name") = "Adam" 
Row3.Item("Product") = "PDA" 
Row3.Item("Location") = "Brisbane" 
table.Rows.Add(Row3) 
m_dataSet = New DataSet() 
m_dataSet.Tables.Add(table) 
Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("Report", m_dataSet.Tables("table"))) 
Catch 
End Try 
Catch ex As Exception 
MsgBox(ex) 
End Try
could u plz help?
 
Last edited by a moderator:
Back
Top