Page 2 of 2
Re: Pass data set to report not working
Posted: Tue Jan 28, 2014 11:49 am
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 (24.88 KiB) Viewed 2742 times
- new data sources not containing all necessary columns

- Capture2.PNG (53.88 KiB) Viewed 2742 times
Thank you.
Re: Pass data set to report not working
Posted: Wed Jan 29, 2014 6:29 am
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
Re: Pass data set to report not working
Posted: Wed Jan 29, 2014 6:45 am
by Alex K.
Hello,
The tables in the Emp and EA datasets should have the "Emp" and "EA" name.
Thank you.
Re: Pass data set to report not working
Posted: Wed Jan 29, 2014 7:04 am
by d3graph
i already have set the name using
foreach ( DataTable table in Emp.Tables)
{
rwcnt += table.Rows.Count;
table.TableName = "Emp";
}
Re: Pass data set to report not working
Posted: Wed Jan 29, 2014 7:31 am
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.
Re: Pass data set to report not working
Posted: Wed Jan 29, 2014 8:45 am
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
Re: Pass data set to report not working
Posted: Wed Jan 29, 2014 1:45 pm
by d3graph
Dear Aleksey
please reply
Re: Pass data set to report not working
Posted: Thu Jan 30, 2014 8:00 am
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.
Re: Pass data set to report not working
Posted: Sat Feb 01, 2014 5:53 am
by d3graph
Re: Pass data set to report not working
Posted: Sun Feb 02, 2014 5:47 am
by Andrew
Great!
Have a nice weekend!