You can bind a section report to data by changing the data source at run time.
Visual Basic.NET code. Paste JUST ABOVE the ReportStart event |
Copy Code
|
---|---|
Dim conn As System.Data.OleDb.OleDbConnection Dim reader As System.Data.OleDb.OleDbDataReader |
Visual Basic.NET code. Paste INSIDE the ReportStart event |
Copy Code
|
---|---|
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "[User Folder]\Samples18\Data\NWIND.mdb" conn = New System.Data.OleDb.OleDbConnection(connString) Dim cmd As New System.Data.OleDb.OleDbCommand("SELECT * FROM Products WHERE UnitPrice = 18", conn) conn.Open() reader = cmd.ExecuteReader() Me.DataSource = reader |
C# code. Paste JUST ABOVE the ReportStart event |
Copy Code
|
---|---|
private static System.Data.OleDb.OleDbConnection conn; private static System.Data.OleDb.OleDbDataReader reader; |
C# code. Paste INSIDE the ReportStart event |
Copy Code
|
---|---|
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"[User Folder]\Samples18\Data\NWIND.mdb"; conn = new System.Data.OleDb.OleDbConnection(connString); System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("SELECT * FROM Products WHERE UnitPrice = 18", conn); conn.Open(); reader = cmd.ExecuteReader(); this.DataSource = reader; |
Visual Basic.NET code. Paste INSIDE the ReportEnd event |
Copy Code
|
---|---|
reader.Close() conn.Close() |
C# code. Paste INSIDE the ReportEnd event |
Copy Code
|
---|---|
reader.Close(); conn.Close(); |
See the UnboundData sample for details on how to use the FetchData event to display the report unbound data.
You can bind a section report to a JSON data source at run time using code.
Visual Basic.NET code. Paste JUST ABOVE the ReportStart event |
Copy Code
|
---|---|
Dim jsonDS As GrapeCity.ActiveReports.Data.JsonDataSource = New GrapeCity.ActiveReports.Data.JsonDataSource() jsonDS.ConnectionString = "jsondoc=https://demodata.mescius.io/northwind/odata/v1/Employees" jsonDS.JsonPath = "$.value[*]" Me.DataSource = jsonDS |
C# code |
Copy Code
|
---|---|
GrapeCity.ActiveReports.Data.JsonDataSource jsonDS = new GrapeCity.ActiveReports.Data.JsonDataSource(); jsonDS.ConnectionString = @"jsondoc=https://demodata.mescius.io/northwind/odata/v1/Employees"; jsonDS.JsonPath = "$.value[*]"; this.DataSource = jsonDS; |