cancel
Showing results for 
Search instead for 
Did you mean: 

Launching a report using RAS under VS.NET 2013

0 Kudos

Hello,

I am an experienced Crystal Reports developer and have built a very simple report using CR Developer 14.  The report is designed to be used against a SQL Server database and an Oracle database.  In the designer, I have no problem loading the same report, and when I run it, connecting to either the SQL Server or Oracle database. 

Using the asp.net application I developed under VS.NET 2013 Professional, different story and bigger problem.  Using the Crystal Reports Engine, I have no problem loading the report and displaying in the crystal reports viewer, provided I load the report first in the designer and save it for the target database.  In other words, using the crystal reports engine/document objects under vs.net, I cannot dynamically set the datasource; the only logon property I cannot set is the db provider!  Thus I am stuck.

However I have been told that the Report Application Server can dynamically set the datasource/all logon properties.  But I have not been able to get a report to launch.  I get the error message attached to this thread. 

I do not understand what to do next; if I need to buy more Crystal components or install/configure my environment better or ?

Can someone please provide me with a list of steps/tasks I can look into that will launch this report?  Again, my launch code is very simple, and it results in a very hard error that I've been grappling with all day.  Please advise!  Thank you.

   Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        Dim myReport As New CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument

        myReport.ReportAppServer = "GEORGED743"

        myReport.Open("C:\Users\George\RoyalDesignDev\CRWeb\CrystalReport1.rpt")

        CrystalReportViewer1.ReportSource = myReport

    End Sub

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member207665
Active Participant
0 Kudos

Hi George,

Below is the same application code to pass Database information programmatically:

==========================================

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

public partial class _Default : System.Web.UI.Page

{

    private ReportDocument northwindCustomersReport;

    private void ConfigureCrystalReports()

    {

        ConnectionInfo connectionInfo = new ConnectionInfo();

        connectionInfo.DatabaseName = "Northwind";

        connectionInfo.UserID = "limitedpermissionaccount";

        connectionInfo.Password = "1234";

        connectionInfo.ServerName = "localhost";

        northwindCustomersReport = new ReportDocument();

        string reportPath = Server.MapPath("NorthwindCustomers.rpt");

        northwindCustomersReport.Load(reportPath);

        crystalReportViewer.ReportSource = northwindCustomersReport;

        SetDBLogonForReport(connectionInfo, northwindCustomersReport);

    }

    private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)

    {

        Tables tables = reportDocument.Database.Tables;

        foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

        {

            TableLogOnInfo tableLogonInfo = table.LogOnInfo;

            tableLogonInfo.ConnectionInfo = connectionInfo;

            table.ApplyLogOnInfo(tableLogonInfo);

        }

    }

    private void Page_Init(object sender, EventArgs e)

    {

        ConfigureCrystalReports();

    }

}

==============================================

Try it out and share your observations.

Regards,

Vinit

0 Kudos

Thank you Don; I appreciate the prompt response.  I've plowed through many of the samples; either I am overwhelmed with the volume and am missing the obvious, or I've not been able to get any of the ones I found to work.  Can you please point me to one specific example or past the example code here in this thread?

0 Kudos

Hi George,

The Reports do not save the password so you need to set the ConnectionInfo in code as well.

Lots of samples on how to, check the Overview Tab, on the left side, for links to sample applications.

Don