Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Crystal Report 10, with visual studio 2010, the report viewer shows only the group section, when i click on any group, it shows me an error of "
No valid report source is available."
Method in Class is :
C#
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;
            }
Posted
Updated 25-Dec-14 20:55pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900