Page 1 of 1

StiMobileDesigner and OnPreviewReport

Posted: Thu Jan 21, 2016 8:55 pm
by jay@bplogix.com
I am trying to get the Preview tab to work for the StiMobileDesigner. I am adding two tables at runtime when the user clicks the preview button. So in the OnPreviewReport, I use the following logic:
Report.DataSources.Clear()

// Add the SQL database
Report.Dictionary.Databases.Add(StiSqlDatabase)

// Add Table1
Report.Dictionary.DataSources.Add(StiSqlSource)
Report.Dictionary.Synchronize();
StiSqlSource_instance.FillColumns();

// Add Table2
Report.Dictionary.DataSources.Add(StiSqlSource)
Report.Dictionary.Synchronize();
StiSqlSource_instance.FillColumns();

Report.Dictionary.Synchronize();

This works perfectly when using StiWebDesigner and the OnGetPreviewDataSet, but using the StiMobileDesigner it returns errors like:
The type 'Reports.Report' already contains a definition for a_Table1DataSource' error CS 0102: The type 'Reports.Report' already contains a definition for 'a_Table2DataSource'

Is the OnPreviewReport where I should be added the data for the preview button?

NOTE: If I am only adding a single table, it works fine.

Re: StiMobileDesigner and OnPreviewReport

Posted: Fri Jan 22, 2016 12:12 pm
by Alex K.
Hello,

We couldn't reproduce this bug.
Please send us a sample project which reproduce the issue for analysis.

Thank you.

Re: StiMobileDesigner and OnPreviewReport

Posted: Tue Jan 26, 2016 3:27 am
by jay@bplogix.com
I attached a simple sample the reproduces this. Just add the reports DLLs to the bin folder.

This sample connects to a SQL Server database and uses two tables (create them on your system first):
a_CatItems with text columns Category and Item and
a_dd with text columns Company and Type

When you use designer.aspx, it will correctly let you design and save the report. But when you hit preview, it shows an error message about a duplicate name. This error only occurs with two or more tables inserted in StiMobileDesigner1_GetPreviewDataSet.

Similar logic works correctly with the Flash report viewer, and the older HTML report viewer.

Re: StiMobileDesigner and OnPreviewReport

Posted: Tue Jan 26, 2016 12:32 pm
by HighAley
Hello.

You are registering two data source with the same name.
Please, change the name of DataTable.

Also try to add all tables in one DataSet and then register it once.

Thank you.

Re: StiMobileDesigner and OnPreviewReport

Posted: Tue Jan 26, 2016 6:16 pm
by jay@bplogix.com
What do you mean "You are registering two data source with the same name." On datasource is called a_CatItems and the other is called a_dd.

Re: StiMobileDesigner and OnPreviewReport

Posted: Wed Jan 27, 2016 7:38 am
by HighAley
Hello.

It was our suppose.
Sorry, but we couldn't reproduce your issue because we don't have data for your report.
Please, send us data for the report and more detailed description of the error.

Thank you.

Re: StiMobileDesigner and OnPreviewReport

Posted: Wed Jan 27, 2016 8:05 am
by jay@bplogix.com
The data is just two simple SQL Server tables. a_CatItems with text columns Category and Item and a_dd with text columns Company and Type

Can you create these tables on your side? ... if not are you asking me to create a SQL Server backup and send that? I think it would be easier if you could create the tables in SQL Server with Management Studio or Visual Studio. Then just place two rows of any data in the tables.

Re: StiMobileDesigner and OnPreviewReport

Posted: Thu Jan 28, 2016 1:58 pm
by HighAley
Hello.

Really you don't need to register DataSet for design time.
The better way is to add StiSqlDatabase with empty connection string.
Then you register data sources and columns.

Code: Select all

//1. ADD connections
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("4m-Database", Cn));

//2 ADD datasources
StiSqlSource DS1 = new StiSqlSource("4m-Database", "DS_Issues", "DS_Issues", "Select * from Tbl_Pro_Issues", true, false);
report.Dictionary.DataSources.Add(DS1);

//3. Add cols
SqlDataAdapter da = new SqlDataAdapter("Select * from Categories", connection);
DataTable dt = new DataTable();
da.FillSchema(dt, SchemaType.Source);

foreach (DataColumn col in dt.Columns)
{
    DS1.Columns.Add(col.ColumnName, col.DataType);
}
In GetPreviewDataSet you should just change connection string.

Code: Select all

((StiSqlDatabase)report.Dictionary.Databases["Connection"]).ConnectionString = ""
Thank you.

Re: StiMobileDesigner and OnPreviewReport

Posted: Thu Jan 28, 2016 9:50 pm
by jay@bplogix.com
I am sorry, I do not understand. Can you update the .CS file to show the changes that would make it correct.
Thanks!

Re: StiMobileDesigner and OnPreviewReport

Posted: Fri Jan 29, 2016 8:43 am
by HighAley
Hello.

Here is your file with all changes.
Designer.aspx.cs
(1.97 KiB) Downloaded 244 times
Thank you.