Reputation: 403
I got the error While I am creating RDLC report. Error is that
" An error has occurred during report processing. Cannot create a connection to data source 'ds_SalesQuotation'. Calling 'Read' when the data reader is closed is not a valid operation. Invalid attempt to call Read when reader is closed. "
I create ds_SalesQuotation.xsd file. In rdlc report give dataset name as 'dsSalesQuotation' and set datasourse as 'ds_SalesQuotation'
my code is on reportviewr(.aspx)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
using (BillingAppEntities context = new BillingAppEntities())
{
var val = context.Sp_SalesQuotation(id);
ReportDataSource rd = new ReportDataSource("dsSalesQuotation", val);
ReportViewer1.LocalReport.DataSources.Add(rd);
ReportViewer1.LocalReport.Refresh();
}
}
}
Is there any mistaken in my code.please check it anybody..
Upvotes: 1
Views: 1389
Reputation: 403
I got my error.I re-write the above code,that is given below.
Now it is working
private void PopulateReport(int id)
{
List<Sp_SalesQuotation_Result> ls = new List<Sp_SalesQuotation_Result>();
using (BillingAppEntities context = new BillingAppEntities())
{
ls = context.Sp_SalesQuotation(id).ToList();
}
ReportDataSource rd = new ReportDataSource("dsSalesQuotation", ls);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rd);
ReportViewer1.LocalReport.Refresh();
}
Upvotes: 0