Page 1 of 1

Preview Not Working As Expected

Posted: Wed Feb 09, 2011 3:32 pm
by jupistar
What is the cause of the following preview to not work. I still get 100 records, not 20:

protected void Page_Load(object sender, EventArgs e)
{
if (Page != null)
{
string keyValue = Page.Request.QueryString.Get("stimulsoft_webdesigner");

if (!IsPostBack && keyValue == null)
{
StiSqlDatabase sti_db = new StiSqlDatabase("My_Data", "Data Source=(local);Initial Catalog=MyDB;Integrated Security=True;");
swdRepDesigner.Report.Dictionary.Databases.Clear();
swdRepDesigner.Report.Dictionary.Databases.Add(sti_db);

StiSqlSource sti_src = new StiSqlSource("My_Data", "Emps", "Emps", "select top 100 * from employees;", true);
swdRepDesigner.Report.Dictionary.DataSources.Clear();
swdRepDesigner.Report.Dictionary.DataSources.Add(sti_src);

swdRepDesigner.Report.Dictionary.Synchronize();
sti_src.FillColumns();

swdRepDesigner.Design();
}
}
}

protected void swdRepDesigner_GetPreviewDataSet(object sender, StiWebDesigner.StiPreviewDataSetEventArgs e)
{
DataSet ds = new DataSet();
using (SqlConnection cn = new SqlConnection("Data Source=(local);Initial Catalog=MyDB;Integrated Security=True;"))
{
cn.Open();

using (SqlDataAdapter ad = new SqlDataAdapter("select top 20 * from employees;", cn))
{
ad.Fill(ds);
}
}
ds.Tables[0].TableName = "Emps";

e.PreviewDataSet = ds;
}

If, instead, I try to alter e.Report.DataSources (i.e. StiSqlSource sti_src = new StiSqlSource("My_Data", "Emps", "Emps", "select top 20 * from employees;", true); swdRepDesigner.Report.Dictionary.DataSources.Clear(); swdRepDesigner.Report.Dictionary.DataSources.Add(sti_src);), then I get an error.

How should this be handled?

Preview Not Working As Expected

Posted: Thu Feb 10, 2011 4:59 am
by Vladimir
Hello,

Before data registration for preview, please try to remove all database connections:

Code: Select all

protected void swdRepDesigner_GetPreviewDataSet(object sender, StiWebDesigner.StiPreviewDataSetEventArgs e)
{
    e.Report.Dictionary.Databases.Clear();

    .....
Thank you.

Preview Not Working As Expected

Posted: Thu Feb 10, 2011 5:59 am
by jupistar
I did that, but now I'm not getting anything in the preview with the following:


protected void swdRepDesigner_GetPreviewDataSet(object sender, StiWebDesigner.StiPreviewDataSetEventArgs e)
{
e.Report.Dictionary.Databases.Clear();

DataSet ds = new DataSet();
using (SqlConnection cn = new SqlConnection("Data Source=(local);Initial Catalog=MyDB;Integrated Security=True;"))
{
cn.Open();

using (SqlDataAdapter ad = new SqlDataAdapter("select top 20 * from employees;", cn))
{
ad.Fill(ds);
}
}
ds.Tables[0].TableName = "Emps";

e.PreviewDataSet = ds;
}

I have verified that ds.Tables[0] contains 20 rows, as it should.

Preview Not Working As Expected

Posted: Thu Feb 10, 2011 6:03 am
by jupistar
I've got a more complicated project with this same code in it. It doesn't work there, either, but in that project I'm finding that the GetPreviewDataSet event is firing twice when the Preview tab is clicked. Why might that happen?

Preview Not Working As Expected

Posted: Fri Feb 11, 2011 6:08 am
by Alex K.
Hello,

Please send us sample project with data which reproduses the issue for analisys on support@stimulsoft.com

Thank you.