I'm wondering if it's possible to get a preview working in mobile designer when report uses a few StiSqlSource data sources?
I've checked a demo project but it's using DataTableSource and not database queries.
Is it possible to build a DataSet on the server and provide it for the report (this does not seem to work though as I get a blank report on preview).
Please advise. Maybe you have a sample code on how to get preview working for database-driven reports?
Code: Select all
protected void StiMobileDesigner1_GetDataSetOnLoad(object sender, Stimulsoft.Report.MobileDesign.StiMobileDesigner.StiLoadReportEventArgs e)
{
DataSet data = new DataSet();
SqlConnection sqlConnection = new SqlConnection(ConnectionString);
sqlConnection.Open();
foreach (var ds in e.Report.DataSources.ToList())
{
string sql = ((StiSqlSource)ds).SqlCommand;
SqlCommand cmdSP = new SqlCommand();
cmdSP.CommandText = sql;
cmdSP.CommandType = CommandType.Text;
cmdSP.Connection = sqlConnection;
SqlDataAdapter da = new SqlDataAdapter(cmdSP);
DataSet dataSet = new DataSet();
da.Fill(dataSet, 0, 0, "default");
DataTable dt = dataSet.Tables[0].Copy();
dt.TableName = ds.Name;
data.Tables.Add(dt);
}
e.Report.RegData(data);
e.Report.Dictionary.Synchronize();
}