hi,
I am my data in crystal report.i am using Report Document class and stored procedure(with two input parameters) to bind data in crystal report viewer.
Parameters of stored procedure can be null.When i display data in report viewer it works but now i want to export/Print data through report viewer print or export button.
and when i click on button it ask for parameters and login information of server.how i solve this problem.
if any one have idea,Please share.......
Thanks in advance.
Loading
Akkiraju IvaturiPosted Sep 27, 2012, 8:41 AM
In the button click event add the following code for connection parameters for login information:
ReportDocument rpt = new ReportDocument();
ConnectionInfo connectionInfo = new ConnectionInfo();
TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
rpt.load("myreport.rpt");
connectionInfo.ServerName = "your server name";
connectionInfo.DatabaseName = "your db name";
connectionInfo.UserId = "your user id";
connectionInfo.Password = "your password";
Tables crTables = rpt.Database.Tables;
foreach(CrystalDecisions.CrystalReports.Engine.Table.CrTable in CrTables)
{
crTableLogonInfo = CrTable.LogOnInfo();
ctTableLogonInfo.ConnectionInfo=crConnectionInfo;
CrTable.ApplyLogOnInfo(crTableLogonInfo);
}
crystalReportViewer1.ReportSource=rpt;
crystalReportViewer1.Refresh();
=================================================
//code for passing parameters
after you load the crystal report as below:
rpt.Load(reportPath);
rpt.setParameterValue("Grouping1",this.ddlgroup1.selectedValue);
rpt.setParameterValue("Grouping2", this.ddlgroup2.selectedValue);
then call
crystalReportViewer1.reportsource = rpt;
crystalreportviewer1.Refresh();
Let me know if you have any questions.