hi..
i've created a crystal report and one crystal report viewer in windows form.
i've two form form1 and form2 in form2 i've kept one button called print.
when i press this button it should print the document into .pdf format.
without using the crystal report viewers print button.
please help me below is my runtime figure.
where form2 consist button1 which is a print button.
when i press i should get the preview of the report in pdf format.
please help me.
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
karthick kumarPosted Sep 21, 2010, 7:31 AM
then in print button click event use this code.
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt =
new CrystalDecisions.CrystalReports.Engine.ReportDocument();
string server = "ServerName"; //Pass your servername
string database ="database";//Pass your databasename
string userid = "Userid";//pass your Userid
string password = "Password"//pass your password
rpt.Load(Server.MapPath("~/Test.rpt"));//for example Test.rpt
for (int i = 0; i < rpt.DataSourceConnections.Count; i++)
rpt.DataSourceConnections[i].SetConnection(server, database, userid, password);
rpt.SetParameterValue(0, Convert.ToInt32(ddlCountry.SelectedValue));//use your parameter value here
rpt.SetParameterValue(1, Convert.ToInt32(ddlState.SelectedValue));//use your parameter value here
rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
HttpContext.Current.Response, true, "Test");
-----If you find my post helpful, Mark it as Answered or Rate the post.------------------------------------