i cannot view my crystal report in my simple web page
i cannot view my crystal report in my simple web page
what seem to be the problem with my code? i cannot view it in my browser. i searched google and so but cannot find the answer. it is been 2 days already that i am looking for solutions. can anyone help thanks.
public partial class WebForm1 : System.Web.UI.Page
{
string connectionString = "server=" +
ConfigurationManager.AppSettings["Server"] + ";uid=" +
ConfigurationManager.AppSettings["User ID"] + ";pwd=" +
ConfigurationManager.AppSettings["Password"] + ";database=" +
ConfigurationManager.AppSettings["Database Name"] +
";Command Timeout=28800;";
protected void Page_Load(object sender, EventArgs e)
{
EmpReport crystalReport = new EmpReport();
dsEmp ds = GetData();
crystalReport.SetDataSource(ds);
this.CrystalReportViewer1.ReportSource = crystalReport;
this.CrystalReportViewer1.RefreshReport();
}
private dsEmp GetData()
{
string query = "SELECT * FROM emp_table";
MySqlConnection con = new MySqlConnection(connectionString);
MySqlCommand cmd = new MySqlCommand(query);
MySqlDataAdapter da = new MySqlDataAdapter();
cmd.Connection = con;
da.SelectCommand = cmd;
dsEmp ds = new dsEmp();
da.Fill(ds, "DataTable1");
return ds;
}
}
can i delete the timeout?
– Randy B.
Jun 29 at 11:02
If you put no timeout then the connection will stay open until either the client close the app or the server close. If the reports takes 10 seconds to generate that mean you need the connection opened for 10 seconds so making the connection timeout to something like 5 or 10 minutes is much more reasonable than 8 hours. The timeout is there for cases where there is an error that occur (other cases exist) and the thing runs forever so when it reach that timeout you set it will force it to stop and close the connection.
– Franck
Jun 29 at 11:11
ok thank u. i am configuring my visual studio now.
– Randy B.
Jun 29 at 11:31
There are a bunch of timeouts to consider. You've set the connection timeout to a large time interval. But there's also the query timeout, the
CommandTimeout
property of the MySqlCommand
object. Then there's the request executionTimeout
. To what values did you set those other two timeouts? Their defaults are 30s, and it's possible one or both are expiring before your PageLoad
method completes.– O. Jones
Jun 29 at 11:32
CommandTimeout
MySqlCommand
executionTimeout
PageLoad
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
It's not about the problem directly but in your sample you have an 8 hours connection timeout. This is some crazy high number you may want to put something more realistic because this can lock some precious resources on the server when an issue occur. The longest report to generate i have ever seen took about an hour and a half. And that was a major airline company doing luggage reporting over a large range of 2-3 months for all their flights.
– Franck
Jun 29 at 10:58