Preview Not Working As Expected
Posted: Wed Feb 09, 2011 3:32 pm
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?
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?