Page 2 of 2

DataSet binding problem

Posted: Mon Jun 14, 2010 6:41 am
by Andrew
Hello,

Could you, please send us the full source code of your web project, because the part you showed is not enough to understand where is the "informe" report taken from and why are data registered in the "re" report.

Thank you.

DataSet binding problem

Posted: Mon Jun 14, 2010 8:23 am
by Rodrigo
ok, sorry.

Now I have an aspx page with a StiWebDesigner control and a button who calls the designer.

In the code file (. Cs) I have only the button“s event, nothing else.
Nothing in the "Page_Load".

The code I wrote belongs entirely to button“s event.

Code: Select all

 protected void Button1_Click(object sender, EventArgs e)
        {

            StiReport re= new StiReport();
            DataSet data= new DataSet();
            bussinesAD bussines= new bussinesAD();

            data= bussines.getBussinesID(2);

            re.RegData(data);
           

            string connString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Proyects Rodrigo\\GesRes.mdf;Integrated Security=True;Connect       Timeout=30;User Instance=True";

            StiSqlDatabase database = new StiSqlDatabase(data.DataSetName,connString);
            re.Dictionary.Databases.Clear();
            re.Dictionary.Databases.Add(database);

            re.Dictionary.Synchronize();

            StiWebDesigner1.Design(re);
}

Thanks for replying so fast.

DataSet binding problem

Posted: Tue Jun 15, 2010 3:13 am
by Andrew
Hello,

Your code is correct, but it only creates a connection to the database. To see the data sources, they also should be created. The best way to do this is with the report designer, but also you can it by code:

StiSqlSource ds = new StiSqlSource("Database.Table1", "Table1", "SELECT * FROM Table1");
re.Dictionary.DataSources.Add(ds);
ds.SynchronizeColumns();

Thank you.

DataSet binding problem

Posted: Tue Jun 15, 2010 4:39 am
by Rodrigo
ok, thanks for your answer, I will put it into practice.

But if my code is correct ... the problem is in the StiWebDesigner? I do not understand why I can not see the preview of the report :S

Thank you.

DataSet binding problem

Posted: Wed Jun 16, 2010 12:46 am
by Vladimir
Hello,

There are two ways to preview a report that would work correctly:

1. Add a new connection to the database, as we have shown above.

2. Connect data directly to the report in the GetPreviewDataSet event:

Code: Select all

protected void StiWebDesigner1_GetPreviewDataSet(object sender, StiWebDesigner.StiPreviewDataSetEventArgs e)
    {
        string appDirectory = HttpContext.Current.Server.MapPath(string.Empty);

        DataSet data = new DataSet();
        data.ReadXml(appDirectory + "\\Data\\Demo.xml");
        data.ReadXmlSchema(appDirectory + "\\Data\\Demo.xsd");

        e.PreviewDataSet = data;
    }
Thank you.

DataSet binding problem

Posted: Wed Jun 16, 2010 3:39 am
by Rodrigo
Perfect!!!

Now it works perfectly.

Thank you very much.


DataSet binding problem

Posted: Wed Jun 16, 2010 4:54 am
by Andrew
Great! :biggrin: