StiMobileDesigner and OnPreviewReport

Stimulsoft Reports.WEB discussion
Post Reply
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

StiMobileDesigner and OnPreviewReport

Post 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.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: StiMobileDesigner and OnPreviewReport

Post by Alex K. »

Hello,

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

Thank you.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Re: StiMobileDesigner and OnPreviewReport

Post 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.
Attachments
SimpleReport.zip
(8.28 KiB) Downloaded 202 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: StiMobileDesigner and OnPreviewReport

Post 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.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Re: StiMobileDesigner and OnPreviewReport

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: StiMobileDesigner and OnPreviewReport

Post 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.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Re: StiMobileDesigner and OnPreviewReport

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: StiMobileDesigner and OnPreviewReport

Post 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.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Re: StiMobileDesigner and OnPreviewReport

Post 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!
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: StiMobileDesigner and OnPreviewReport

Post by HighAley »

Hello.

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