locked
No Valid report source is available RRS feed

  • Question

  • User2128666432 posted

    Been trying all day to get this report done programmatically, it will work once i dynamically create it but when i try to code it it gives me the error, "No valid report source is available".

    This is my code
    protected void cmdShorReport_Click(object sender, EventArgs e)
    {
         ReportDocument Report = new ReportDocument();
         Report.Load("C:\\Report.rpt");
         crvReports.ReportSource = Report;
         crvReports.RefreshReport();
    }

    I downloaded the latest version of  sap crystal reports for vs2010. For the life of me i cant get this thing working programmatically.

    Help plz!

    :'( 

    Wednesday, August 10, 2011 3:14 PM

Answers

  • User2128666432 posted

    Interesting thing happened. When i put the login info for the server into code, then i'm able to generate the report programmatically, if i remove it, i get back the "No valid report source" error. 

    I'm guess the connection info to the server/db is required to complete the report as the darn thing wont show at all.  I placed the code in a function as shown below. For anyone who has this problem include the login parameters below.

    private void reportLogin()
    {
    ReportDocument cryRpt = new ReportDocument();
    TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
    TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
    ConnectionInfo crConnectionInfo = new ConnectionInfo();
    Tables CrTables ;

    cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt");

    crConnectionInfo.ServerName = "YOUR SERVER NAME";
    crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
    crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
    crConnectionInfo.Password = "YOUR DATABASE PASSWORD";

    CrTables = cryRpt.Database.Tables ;
    foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
    {
    crtableLogoninfo = CrTable.LogOnInfo;
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    CrTable.ApplyLogOnInfo(crtableLogoninfo);
    }

    crystalReportViewer1.ReportSource = cryRpt;
    crystalReportViewer1.Refresh();   
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 11, 2011 11:24 AM

All replies

  • User1196771204 posted

    hi there,

    please have a look at http://forums.sdn.sap.com/thread.jspa?threadID=1688408 

    Thursday, August 11, 2011 12:55 AM
  • User2128666432 posted

    I'm sorry, that doesnt help due to the fact that i'm using vs2010. I cant even define a new instance of the CrystalReportSource in code behind. I just cant understand why it would allow me to load the report source when all the examples i have gone t hrough say they same thing. I just seem to find out what it is i'm doing wrong. I t ried this method and it didnt work either. (This is done below a button click method)

    CrystalDecisions.Web.Report Report = new CrystalDecisions.Web.Report();
    Report.FileName = "Report.rpt";
    crsReports.Report = Report; //This crystalreportsource is an object on the design page
    crvReports.ReportSource = crsReports;
    crvReports.Refesh();

    That doesnt work either. I knwo the report loads because i've tested for it. However i jsut cant figure out why its not a valid source. Does anyone have a working report in vs2010 and if so can i see your code please.

    Thursday, August 11, 2011 10:48 AM
  • User2128666432 posted

    Interesting thing happened. When i put the login info for the server into code, then i'm able to generate the report programmatically, if i remove it, i get back the "No valid report source" error. 

    I'm guess the connection info to the server/db is required to complete the report as the darn thing wont show at all.  I placed the code in a function as shown below. For anyone who has this problem include the login parameters below.

    private void reportLogin()
    {
    ReportDocument cryRpt = new ReportDocument();
    TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
    TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
    ConnectionInfo crConnectionInfo = new ConnectionInfo();
    Tables CrTables ;

    cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt");

    crConnectionInfo.ServerName = "YOUR SERVER NAME";
    crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
    crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
    crConnectionInfo.Password = "YOUR DATABASE PASSWORD";

    CrTables = cryRpt.Database.Tables ;
    foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
    {
    crtableLogoninfo = CrTable.LogOnInfo;
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    CrTable.ApplyLogOnInfo(crtableLogoninfo);
    }

    crystalReportViewer1.ReportSource = cryRpt;
    crystalReportViewer1.Refresh();   
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 11, 2011 11:24 AM