public static object ConnectionForReports(ReportDocument objReport) { SqlConnection cn = null; cn = new SqlConnection(Properties.Settings.Default.CMScon); CrystalDecisions.Shared.TableLogOnInfo logOnInfo = null; logOnInfo = objReport.Database.Tables[0].LogOnInfo; logOnInfo.ConnectionInfo.ServerName = cn.DataSource; logOnInfo.ConnectionInfo.DatabaseName = cn.Database; logOnInfo.ConnectionInfo.UserID = "sa"; logOnInfo.ConnectionInfo.Password = "********"; objReport.Database.Tables[0].ApplyLogOnInfo(logOnInfo); return objReport; } And the code behind is: protected void CmdPreview_Click(object sender, ImageClickEventArgs e) { InquiryReports objReport = new InquiryReports(); string vSelectionFormula = null; ReportDocument objReports = (ReportDocument)MethodClass.ConnectionForReports(objReport); vSelectionFormula = "{CompalintView.ComplaintStatus}='" + CboCompStatus.Text + "'"; InquiryRptViewer.SelectionFormula = vSelectionFormula; InquiryRptViewer.ReportSource = objReports; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)