p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Crystal Reports (http://p2p.wrox.com/forumdisplay.php?f=113)
-   -   Invalid attempt to FieldCount when reader is close (http://p2p.wrox.com/showthread.php?t=36395)

hwajunsong December 22nd, 2005 09:22 PM

Invalid attempt to FieldCount when reader is close
 
I am using VS 2005 and created crystal report file abc.rpt and when I choose preview it shows the content correctly (The report was created using calling stored procedure which had 2 params). When I inserted this abc.rpt to one of my asp.net form, I get the following error message after through with Page_Load().

Stack Trace:


[InvalidOperationException: Invalid attempt to FieldCount when reader is closed.]
   System.Data.SqlClient.SqlDataReader.get_FieldCount () +62
   System.Data.Common.DbEnumerator.BuildSchemaInfo() +76
   System.Data.Common.DbEnumerator.MoveNext() +35
   System.Web.UI.WebControls.ListControl.PerformDataB inding(IEnumerable dataSource) +688
   System.Web.UI.WebControls.ListControl.OnDataBindin g(EventArgs e) +81
   System.Web.UI.WebControls.ListControl.PerformSelec t() +32
   System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +99
   CrystalDecisions.Web.CrystalReportSource.GetContro lParameterValue(ControlParameter parameter) +332
   CrystalDecisions.Web.CrystalReportSource.GetParame terValue(Parameter parameter) +140
   CrystalDecisions.Web.CrystalReportSource.BindContr olParameter(Parameter parameter) +513
   CrystalDecisions.Web.CrystalReportSource.DataBindP arameters() +191
   CrystalDecisions.Web.CrystalReportSource.EnsurePar ameters(Boolean forceDataBind) +90
   CrystalDecisions.Web.CrystalReportSource.LoadCompl eteEventHandler(Object sender, EventArgs e) +47
   System.Web.UI.Page.OnLoadComplete(EventArgs e) +96
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4085

Can anybody tell me how to fix this problem?
Thank you.



hwajunsong December 28th, 2005 01:18 PM

The problem was solved when I set the parameters from the code instead from the UI's property for Parameters. In another word, instead of using Parameter Colelction Editor fomr MS VS 2005, I entered the following lines instead;
crDailySource.ReportDocument.SetParameterValue("@m ilestones", ddlMilestones.SelectedItem.Text);
crDailySource.ReportDocument.SetParameterValue("@r elease", ddlRelease.SelectedItem.Text);
Now, it's working like charm :D



All times are GMT -4. The time now is 07:50 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.