OK I tried everything that I can think of but this problem is a nightmare and now i'm asking for some help here. (First time with CR)
So I'll describe what I have done :
I created a stored procedure with 3 parameters to pass (@IDEmp, @DateDebut and @DateFin) in SQL server 2008 and I use it in my crystal report. Everything works well so far. The problem is not in SQL I know that.
So I created my report and everyhing works great when I try it.
After that I created a ASP page to be able to give the parameters to the report to get rip of the parameter prompt. ( by the way I'm using Session to pass the parameter to another another page. It looks like that:
So on ViewReport.aspx (The one with crystal report viewer) I use the Session to get the parameters
protected void RapportEmployeOnly()
{
//Instantiate variables
Session["Parameter"] = null;
Session["Report"] = null;
ReportDocument report = new ReportDocument();
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
int userID = Convert.ToInt32(Request.QueryString["Employe"]);
//Set instances for input parameter 1
paramField.Name = "@IDEmp";
paramDiscreteValue.Value = userID;
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
//Instantiate variables DateDebut
ParameterField paramDateDebut = new ParameterField();
ParameterDiscreteValue paramDiscreteDateDebut = new ParameterDiscreteValue();
DateTime DateDebut = Convert.ToDateTime(Request.QueryString["DateDebut"]);
//Set instances for input parameter DateDebut
paramDateDebut.Name = "@DateDebut";
paramDiscreteDateDebut.Value = DateDebut;
paramDateDebut.CurrentValues.Add(paramDiscreteDateDebut);
paramFields.Add(paramDateDebut);
//Instantiate variables DateFin
ParameterField paramDateFin = new ParameterField();
ParameterDiscreteValue paramDiscreteDateFin = new ParameterDiscreteValue();
DateTime DateFin = Convert.ToDateTime(Request.QueryString["DateFin"]);
//Set instances for input parameter DateFin
paramDateFin.Name = "@DateFin";
paramDiscreteDateFin.Value = DateFin;
paramDateFin.CurrentValues.Add(paramDiscreteDateFin);
//Add the paramField to paramFields
paramFields.Add(paramDateFin);
rptviewer.ParameterFieldInfo = paramFields;
report.Load(Server.MapPath("rapports/RapportEmploye.rpt"));
report.SetDatabaseLogon("Username", "password");
rptviewer.ReportSource = report
report.Refresh();
}
In Page_Init() I call
RapportEmployeOnly();
Ok now that you know what my code looks like. My problem is the date but I don't know what's going on! When I press the btnEmploye, the report give me the report and everything works great but if I change the page/ print / export (anything) I get a pop "Please wait while the document is being processed." and it never goes away. I don't get any error or anything.
And if I delete this :
//Instantiate variables DateDebut
ParameterField paramDateDebut = new ParameterField();
ParameterDiscreteValue paramDiscreteDateDebut = new ParameterDiscreteValue();
DateTime DateDebut = Convert.ToDateTime(Request.QueryString["DateDebut"]);
//Set instances for input parameter DateDebut
paramDateDebut.Name = "@DateDebut";
paramDiscreteDateDebut.Value = DateDebut;
paramDateDebut.CurrentValues.Add(paramDiscreteDateDebut);
paramFields.Add(paramDateDebut);
//Instantiate variables DateFin
ParameterField paramDateFin = new ParameterField();
ParameterDiscreteValue paramDiscreteDateFin = new ParameterDiscreteValue();
DateTime DateFin = Convert.ToDateTime(Request.QueryString["DateFin"]);
//Set instances for input parameter DateFin
paramDateFin.Name = "@DateFin";
paramDiscreteDateFin.Value = DateFin;
paramDateFin.CurrentValues.Add(paramDiscreteDateFin);
//Add the paramField to paramFields
paramFields.Add(paramDateFin);
It works well (paging, export, print, etc) but the paramaterPrompt popup appears before generating the report to set the parameter @DateDebut and @DateFin and I cannot have this.
I tried this before using page init() but it didn't work. When I was changing the page of the report it get stuck at the second page and I wasn't using date parameter yet. About (!ispostback), i'm getting a error that it cannot find the report when paging
or pressing any bottom in the report.
basically Crystal report required connection string meand logon parameter and database stored procedure parameter on every post back so it should be work in page load and provide everytime all information.
Farrukh Abbas
~Please Mark As Answer, if one or multiple posts, which helped you in your problem. So that it might be useful for others~
I've read that because the binding of the report occurs in the Page_Load() and the CRV paging resets every time the report is rebinded. It was suggested to move this into Page_Init() which should only fire once, save the report in Session state, and
then rebind on post backs.
But anyway if I make it to work in Page_Load, I will still have the problem with the date parameter. The report works fine and the others parameters too (except the date) in Page_init()
flauziere
Member
4 Points
7 Posts
Crystal report hangs
Jun 29, 2012 02:32 PM|LINK
Hi ASP.net!
OK I tried everything that I can think of but this problem is a nightmare and now i'm asking for some help here. (First time with CR)
So I'll describe what I have done :
I created a stored procedure with 3 parameters to pass (@IDEmp, @DateDebut and @DateFin) in SQL server 2008 and I use it in my crystal report. Everything works well so far. The problem is not in SQL I know that.
So I created my report and everyhing works great when I try it.
After that I created a ASP page to be able to give the parameters to the report to get rip of the parameter prompt. ( by the way I'm using Session to pass the parameter to another another page. It looks like that:
protected void btnEmploye_Click(object sender, EventArgs e) { //Variables int userID = Convert.ToInt32(ddlEmploye.SelectedValue); DateTime DateDebut; DateTime DateFin; if (CbxDate.Checked == true) { DateDebut = Convert.ToDateTime(txtDateDebut.Text); DateFin = Convert.ToDateTime(txtDateFin.Text); } else { DateDebut = DateTime.MinValue; DateFin = DateTime.Now; } //Chargement d'une nouvelle fenetre avec parametre Employe Response.Write("<script type='text/javascript'>window.open('ViewReport.aspx?Employe=" + userID + "&DateDebut=" + DateDebut + "&DateFin=" + DateFin + "&flag=1', '_blank', 'width=1175,height=925');</script>"); }So on ViewReport.aspx (The one with crystal report viewer) I use the Session to get the parameters
protected void RapportEmployeOnly() { //Instantiate variables Session["Parameter"] = null; Session["Report"] = null; ReportDocument report = new ReportDocument(); ParameterField paramField = new ParameterField(); ParameterFields paramFields = new ParameterFields(); ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue(); int userID = Convert.ToInt32(Request.QueryString["Employe"]); //Set instances for input parameter 1 paramField.Name = "@IDEmp"; paramDiscreteValue.Value = userID; paramField.CurrentValues.Add(paramDiscreteValue); paramFields.Add(paramField); //Instantiate variables DateDebut ParameterField paramDateDebut = new ParameterField(); ParameterDiscreteValue paramDiscreteDateDebut = new ParameterDiscreteValue(); DateTime DateDebut = Convert.ToDateTime(Request.QueryString["DateDebut"]); //Set instances for input parameter DateDebut paramDateDebut.Name = "@DateDebut"; paramDiscreteDateDebut.Value = DateDebut; paramDateDebut.CurrentValues.Add(paramDiscreteDateDebut); paramFields.Add(paramDateDebut); //Instantiate variables DateFin ParameterField paramDateFin = new ParameterField(); ParameterDiscreteValue paramDiscreteDateFin = new ParameterDiscreteValue(); DateTime DateFin = Convert.ToDateTime(Request.QueryString["DateFin"]); //Set instances for input parameter DateFin paramDateFin.Name = "@DateFin"; paramDiscreteDateFin.Value = DateFin; paramDateFin.CurrentValues.Add(paramDiscreteDateFin); //Add the paramField to paramFields paramFields.Add(paramDateFin); rptviewer.ParameterFieldInfo = paramFields; report.Load(Server.MapPath("rapports/RapportEmploye.rpt")); report.SetDatabaseLogon("Username", "password"); rptviewer.ReportSource = report report.Refresh(); }In Page_Init() I call
RapportEmployeOnly();
Ok now that you know what my code looks like. My problem is the date but I don't know what's going on! When I press the btnEmploye, the report give me the report and everything works great but if I change the page/ print / export (anything) I get a pop "Please wait while the document is being processed." and it never goes away. I don't get any error or anything.
And if I delete this :
//Instantiate variables DateDebut ParameterField paramDateDebut = new ParameterField(); ParameterDiscreteValue paramDiscreteDateDebut = new ParameterDiscreteValue(); DateTime DateDebut = Convert.ToDateTime(Request.QueryString["DateDebut"]); //Set instances for input parameter DateDebut paramDateDebut.Name = "@DateDebut"; paramDiscreteDateDebut.Value = DateDebut; paramDateDebut.CurrentValues.Add(paramDiscreteDateDebut); paramFields.Add(paramDateDebut); //Instantiate variables DateFin ParameterField paramDateFin = new ParameterField(); ParameterDiscreteValue paramDiscreteDateFin = new ParameterDiscreteValue(); DateTime DateFin = Convert.ToDateTime(Request.QueryString["DateFin"]); //Set instances for input parameter DateFin paramDateFin.Name = "@DateFin"; paramDiscreteDateFin.Value = DateFin; paramDateFin.CurrentValues.Add(paramDiscreteDateFin); //Add the paramField to paramFields paramFields.Add(paramDateFin);It works well (paging, export, print, etc) but the paramaterPrompt popup appears before generating the report to set the parameter @DateDebut and @DateFin and I cannot have this.
Any idea?
morefays
Participant
1125 Points
235 Posts
Re: Crystal report hangs
Jul 04, 2012 11:41 AM|LINK
Call RapportEmployeOnly(); in page load instead of page init() and check with out using ispostback=true let me know that is working or not
~Please Mark As Answer, if one or multiple posts, which helped you in your problem. So that it might be useful for others~
dotnetfarrukhabbasblogspot
flauziere
Member
4 Points
7 Posts
Re: Crystal report hangs
Jul 04, 2012 12:42 PM|LINK
I tried this before using page init() but it didn't work. When I was changing the page of the report it get stuck at the second page and I wasn't using date parameter yet. About (!ispostback), i'm getting a error that it cannot find the report when paging or pressing any bottom in the report.
morefays
Participant
1125 Points
235 Posts
Re: Crystal report hangs
Jul 05, 2012 11:03 AM|LINK
basically Crystal report required connection string meand logon parameter and database stored procedure parameter on every post back so it should be work in page load and provide everytime all information.
~Please Mark As Answer, if one or multiple posts, which helped you in your problem. So that it might be useful for others~
dotnetfarrukhabbasblogspot
flauziere
Member
4 Points
7 Posts
Re: Crystal report hangs
Jul 05, 2012 12:13 PM|LINK
From another post in this forum :
I've read that because the binding of the report occurs in the Page_Load() and the CRV paging resets every time the report is rebinded. It was suggested to move this into Page_Init() which should only fire once, save the report in Session state, and then rebind on post backs.
But anyway if I make it to work in Page_Load, I will still have the problem with the date parameter. The report works fine and the others parameters too (except the date) in Page_init()
morefays
Participant
1125 Points
235 Posts
Re: Crystal report hangs
Jul 08, 2012 09:24 AM|LINK
try to provide parameter like this
report.SetParameterValue("DateFin", Convert.ToDateTime(Request.QueryString["DateFin"])); then tell me its work or still problem
~Please Mark As Answer, if one or multiple posts, which helped you in your problem. So that it might be useful for others~
dotnetfarrukhabbasblogspot
flauziere
Member
4 Points
7 Posts
Re: Crystal report hangs
Jul 09, 2012 12:27 PM|LINK
No it didn't works. Any other idea?
morefays
Participant
1125 Points
235 Posts
Re: Crystal report hangs
Jul 10, 2012 05:18 AM|LINK
share you source code and also mention complete error shown in a page
~Please Mark As Answer, if one or multiple posts, which helped you in your problem. So that it might be useful for others~
dotnetfarrukhabbasblogspot
flauziere
Member
4 Points
7 Posts
Re: Crystal report hangs
Jul 10, 2012 02:16 PM|LINK
What do you mean? I already posted my source code. There is no error, only the waiting popup.