Pass data set to report not working

Stimulsoft Reports.WEB discussion
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Pass data set to report not working

Post by Alex K. »

Hello,

- you need use the following code for remove old data:

Code: Select all

report.Dictionary.Databases.Clear();
report.Dictionary.DataSources.Clear();
- your new registered data should have the same name.
Capture1.PNG
Capture1.PNG (24.88 KiB) Viewed 2740 times
- new data sources not containing all necessary columns
Capture2.PNG
Capture2.PNG (53.88 KiB) Viewed 2740 times
Thank you.
d3graph
Posts: 13
Joined: Mon Jan 06, 2014 6:27 am

Re: Pass data set to report not working

Post by d3graph »

thanks for your reply

how do we register the data with the same name

i have try to do it like

Code: Select all

            report.Dictionary.Databases.Clear();
            report.Dictionary.DataSources.Clear();
            
            report.RegData("Con", Emp);

            report.RegData("Con", EA);

            report.Render(true);

            StiWebViewer1.Report = report;


and i have removed the id field that is not required

and try to execute but now i am getting the error

Code: Select all

c:\Users\Shree\AppData\Local\Temp\tn4dqryx.0.cs(35,40) : error CS0103: The name 'Emp' does not exist in the current contextc:\Users\Shree\AppData\Local\Temp\tn4dqryx.0.cs(40,40) : error CS0103: The name 'Emp' does not exist in the current contextc:\Users\Shree\AppData\Local\Temp\tn4dqryx.0.cs(45,40) : error CS0103: The name 'EA' does not exist in the current contextc:\Users\Shree\AppData\Local\Temp\tn4dqryx.0.cs(50,40) : error CS0103: The name 'EA' does not exist in the current contextc:\Users\Shree\AppData\Local\Temp\tn4dqryx.0.cs(55,40) : error CS0103: The name 'EA' does not exist in the current context
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Pass data set to report not working

Post by Alex K. »

Hello,

The tables in the Emp and EA datasets should have the "Emp" and "EA" name.

Thank you.
d3graph
Posts: 13
Joined: Mon Jan 06, 2014 6:27 am

Re: Pass data set to report not working

Post by d3graph »

i already have set the name using

foreach ( DataTable table in Emp.Tables)
{
rwcnt += table.Rows.Count;
table.TableName = "Emp";
}
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Pass data set to report not working

Post by Alex K. »

Hello,

Please try to pass the data in two tables "Emp" and "EA", then add them in dataset "Con" and then register this dataset.

Thank you.
d3graph
Posts: 13
Joined: Mon Jan 06, 2014 6:27 am

Re: Pass data set to report not working

Post by d3graph »

I try like

Code: Select all


string sql = "Select Name,FatherName from Employee Where ID = 24";
            DataSet Con = new DataSet();
            Con.DataSetName = "Con";
            string connectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlDataAdapter adapter = new SqlDataAdapter(sql +";SELECT Attdate,InTime,OutTime FROM Attendance WHERE F_EmpMaster = 24;",  connection);
                adapter.TableMappings.Add("Table", "Emp");
                adapter.TableMappings.Add("Table1", "EA");
                adapter.Fill(Con); 
            }
 
            string appDirectory = HttpContext.Current.Server.MapPath(string.Empty);
            // Load report
            StiReport report = new StiReport();
            report.Load(appDirectory + "\\Report\\AttReport.mrt");

            report.Dictionary.Databases.Clear();
            report.Dictionary.DataSources.Clear();
            
            report.RegData(Con);        

           StiWebViewer1.Report = report;
 
but still the same error
i have try to open in web designer like you did .please look at attached image
can you please make this sample application to work

Regards
Attachments
error 1.png
error 1.png (170.29 KiB) Viewed 2732 times
d3graph
Posts: 13
Joined: Mon Jan 06, 2014 6:27 am

Re: Pass data set to report not working

Post by d3graph »

Dear Aleksey

please reply
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Pass data set to report not working

Post by Alex K. »

Hello,

Please check the following code:

Code: Select all

protected void Page_Load(object sender, EventArgs e)
{
    DataSet ds = new DataSet("Con");

    string sql = "Select Name,FatherName from Employee Where ID = 24";
    DataTable emp = new DataTable();
    emp = SqlClientUtility.ExecuteDataTable("ApplicationServices", CommandType.Text, sql, null);
    emp.TableName = "Emp";
    ds.Tables.Add(emp);

    DataTable ea = new DataTable();

    ea = SqlClientUtility.ExecuteDataTable("ApplicationServices", CommandType.Text, "SELECT Attdate,InTime,OutTime FROM Attendance WHERE F_EmpMaster = 24", null);
    ea.TableName = "EA";
    ds.Tables.Add(ea);

    string appDirectory = HttpContext.Current.Server.MapPath(string.Empty);
    // Load report
    StiReport report = new StiReport();
    report.Load(appDirectory + "\\Report\\AttReport.mrt");
    report.Dictionary.Databases.Clear();
    report.Dictionary.DataSources.Clear();

    report.RegData(ds);
    report.Dictionary.Synchronize();
    report.Render();
    StiWebViewer1.Report = report;
}
Thank you.
d3graph
Posts: 13
Joined: Mon Jan 06, 2014 6:27 am

Re: Pass data set to report not working

Post by d3graph »

Thank You very much :) :) :) :)

it is working great .
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Re: Pass data set to report not working

Post by Andrew »

Great!

Have a nice weekend!
Post Reply