Hi All,
As we know that we can bind a stimulsoft report(.mrt file) with sql query and then assign to report designer in the following way
report.Load(path);
//get connection string from web.config file
string connectionString = "connection string is given here"
//write query
string sqlQuery = "Select * from Products";
//create data source and connect the report using the connection string
StiSqlSource myDataSource = new StiSqlSource("MyConnection", "myDataSource", "myDataSource", sqlQuery);
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new StiSqlDatabase("MyConnection", connectionString));
report.Dictionary.DataSources.Clear();
report.Dictionary.DataSources.Add(myDataSource);
report.Dictionary.Synchronize();
report.Dictionary.Connect();
report.DataSources["myDataSource"].SynchronizeColumns();
//assign to stimulsoft report designer
StiWebDesigner1.Design(report);
Doing the above will open the report in stimulsoft report designer, where we can drag drop datasource fields to design the report and then can save the report.
My problem is that I want to provide object dataSource instead of the sql query and connection.
I've a business class which returns me the collection of whole of the data. So how I can use the fields of my business class in the report designer?
In other words, how I can use object datasource for designing the reports in stimulsoft designer dynamically?
Please reply me asap, so that I can come out of this problem asap.:emb:
Working with object datasource using stimulsoft reports.net
-
- Posts: 14
- Joined: Thu May 14, 2009 2:06 am
Working with object datasource using stimulsoft reports.net
Hello Rajesh,
You can use following code to register business object in report in runtime:
Thank you.
You can use following code to register business object in report in runtime:
Code: Select all
report.RegData("NameOfYourBusinessObjectInReport", businessObject);
-
- Posts: 14
- Joined: Thu May 14, 2009 2:06 am
Working with object datasource using stimulsoft reports.net
Hi Jan,
Thanks for the reply.
I've registered business object, but no datasource is shown in the report designer.
I can give you a test scenario as follows:
let's say there is a class with name "TestReport"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Reporting
{
public class TestReport
{
public TestReport()
{
}
public string FirstName { get; set; }
public string LastName { get; set; }
public int RollNo { get; set; }
}
}
Now I created a new report and register the business object.
StiReport report = new StiReport();
TestReport tr = new TestReport();
report.RegData("MySource", tr);
Then assigned this report to the designer.
StiWebDesigner1.Design(report);
Now the designer is shown, but there is no datasource on the designer.
Do I need to add dataSource using
report.Dictionary.DataSources.Add(myDataSource);
If yes then which dataSource to be added. If no, then how dataSource in this case will appear on the desginer?
Thanks for the reply.
I've registered business object, but no datasource is shown in the report designer.
I can give you a test scenario as follows:
let's say there is a class with name "TestReport"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Reporting
{
public class TestReport
{
public TestReport()
{
}
public string FirstName { get; set; }
public string LastName { get; set; }
public int RollNo { get; set; }
}
}
Now I created a new report and register the business object.
StiReport report = new StiReport();
TestReport tr = new TestReport();
report.RegData("MySource", tr);
Then assigned this report to the designer.
StiWebDesigner1.Design(report);
Now the designer is shown, but there is no datasource on the designer.
Do I need to add dataSource using
report.Dictionary.DataSources.Add(myDataSource);
If yes then which dataSource to be added. If no, then how dataSource in this case will appear on the desginer?
-
- Posts: 14
- Joined: Thu May 14, 2009 2:06 am
Working with object datasource using stimulsoft reports.net
Hi
After doing some more RnD, I'm able to bind data using following code: :biggrin:
BusinessLib.Referral.GetReferral returns single row with lot of columns.
There are around 100 fields which I've placed on the Refferal.mrt file.
Now problem is that it is taking a lot of minutes in registering the data.
In other words..when debugger reach to
report.RegData("MySource", redDet);
Then it stands here for lot of minutes and then nothing appear after that.....or you can say it behaves like not responding.
What to do as of now?
After doing some more RnD, I'm able to bind data using following code: :biggrin:
Code: Select all
StiReport report = new StiReport();
report.Load("D:\\TestReports\\Refferal.mrt");
BusinessLib.Referral redDet = BusinessLib.Referral.GetReferral();
report.RegData("MySource", redDet);
report.Dictionary.DataSources.Clear();
report.Dictionary.Synchronize();
report.Dictionary.Connect();
StiWebDesigner1.Design(report);
There are around 100 fields which I've placed on the Refferal.mrt file.
Now problem is that it is taking a lot of minutes in registering the data.
In other words..when debugger reach to
report.RegData("MySource", redDet);
Then it stands here for lot of minutes and then nothing appear after that.....or you can say it behaves like not responding.
What to do as of now?
Working with object datasource using stimulsoft reports.net
Hello Rajesh,
Please use following code before RegData method:
Thank you.
Please use following code before RegData method:
Code: Select all
StiOptions.Dictionary.BusinessObjects.MaxLevel = 3;