One .mrt file for different reports
-
- Posts: 7
- Joined: Tue Nov 01, 2011 3:20 am
One .mrt file for different reports
Hi,
I'm evaluating your product and I think we are going to buy them.
However I have an important question, which is: Can I load one generic .mrt file and change the SQL Queries on runtime? So I can feed it different queries on code behind?
If such scenario is doable, please do let me know how.
P.S: I'm using Stimulsoft Web Viewer and Designer.
Your help would be appreciated.
Thanks.
I'm evaluating your product and I think we are going to buy them.
However I have an important question, which is: Can I load one generic .mrt file and change the SQL Queries on runtime? So I can feed it different queries on code behind?
If such scenario is doable, please do let me know how.
P.S: I'm using Stimulsoft Web Viewer and Designer.
Your help would be appreciated.
Thanks.
One .mrt file for different reports
Hello,
As a way, you can use the following code:
Thank you.
As a way, you can use the following code:
Code: Select all
((StiSqlSource)report.Dictionary.DataSources["DataSourceName"]).SqlCommand = newSqlCommand;
-
- Posts: 7
- Joined: Tue Nov 01, 2011 3:20 am
One .mrt file for different reports
Thank you,
What about the Fields? how can I add Fields "on the fly" on runtime?
What about the Fields? how can I add Fields "on the fly" on runtime?
One .mrt file for different reports
Hello,
You can use the following code.
New connection string:
Add DataSources:
Add Columns:
Add Relations:
Thank you.
You can use the following code.
New connection string:
Code: Select all
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", newConnectionString));
Code: Select all
StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM DS1", true, false);
report.Dictionary.DataSources.Add(DS1);
Code: Select all
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
Code: Select all
StiDataRelation dataRelation = new StiDataRelation("MyRelation", parentDS, childDS, new string[] { "Field" }, new string[] { "Field" });
report.Dictionary.RegRelations();
report.Dictionary.Relations.Add(dataRelation);
-
- Posts: 7
- Joined: Tue Nov 01, 2011 3:20 am
One .mrt file for different reports
Dear Aleksey,
I tried your code and changed
to
However it did not return any data.
: is "DS1" should be a name in the .mrt file?
Please advice what I am missing.
Thanks,
Bilal
I tried your code and changed
Code: Select all
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
Code: Select all
foreach (DataColumn col in DS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
Code: Select all
StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM DS1", true, false);
Please advice what I am missing.
Thanks,
Bilal
One .mrt file for different reports
Hello,
Please check the following code:
Thank you.
Please check the following code:
Code: Select all
SqlConnection conn = new SqlConnection();
SqlDataAdapter da = new SqlDataAdapter("select * from DS1", conn);
DataTable dataTableDS1 = new DataTable();
conn.Open();
da.Fill(dataTableDS1);
StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM DS1", true, false);
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
-
- Posts: 7
- Joined: Tue Nov 01, 2011 3:20 am
One .mrt file for different reports
Hi Aleksey,
I tried you code. However it still returning empty data and even no columns names are displayed in the report.
Below is my code:
I tried you code. However it still returning empty data and even no columns names are displayed in the report.
Below is my code:
Code: Select all
strConn = Session["strCustomerConn"].ToString();
StiReport report = new StiReport();
SqlDataAdapter da = new SqlDataAdapter("select * from students", strConn);
DataTable dataTableDS1 = new DataTable();
da.Fill(dataTableDS1);
string appDirectory = HttpContext.Current.Server.MapPath(string.Empty);
report.Load(appDirectory + "./App_Data/Report.mrt");
StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM students", true, false);
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
StiWebViewer1.Report = report;
One .mrt file for different reports
Hello,
You need add the following code:
Thank you.
You need add the following code:
Code: Select all
...
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", connectionString));
report.Dictionary.DataSources.Add(DS1);
StiWebViewer1.Report = report;
-
- Posts: 7
- Joined: Tue Nov 01, 2011 3:20 am
One .mrt file for different reports
Hi Aleksey,
I dont know what I am missing...it still returns no data!
If you can attach me a sample of my scenario described above (including the .mrt file) it would me more than appreciated.
Thanks,
Bilal
I dont know what I am missing...it still returns no data!
If you can attach me a sample of my scenario described above (including the .mrt file) it would me more than appreciated.
Thanks,
Bilal
One .mrt file for different reports
Hello,
Please send your sample which reproduces the issue for analysis.
Thank you.
Please send your sample which reproduces the issue for analysis.
Thank you.