Crystal Reports and data Binding w czasie wykonywania

Walczę z tym od 4 dni. Mam bardzo prosty raport kryształowy (używam go tylko dla potwierdzenia koncepcji). Raport jest powiązany z bazą danych i wyświetlam tylko jedno pole z jednej tabeli w bazie danych. Brak podraportów. Został utworzony za pomocą Crystal Reports 2008. Muszę wyświetlić ten raport w mojej aplikacji internetowej .Net MVC, ale muszę być w stanie zmienić informacje o połączeniu z bazą danych od tej aplikacji. będzie używany przeciwko różnym bazom danych o identycznej strukturze tabeli. Dlatego stworzyłem standardowy formularz internetowy i przeciągnąłem do niego CrystalReportViewer i CrystalReportSource.

To jest mój kod:

protected void Page_Load(object sender, EventArgs e)
    {
        this.CrystalReportSource1.EnableCaching = false;
        this.CrystalReportSource1.ReportDocument.Load(@"C:\ReportName.rpt");

        //1)  I get the data connection variables from my app - this part works well  
              and is irrelevant in this case.

 //2) Once I have the data I need to apply it to the connection of the report
 ConnectionInfo crConnection = new ConnectionInfo();
 crConnection.UserID = userID;
 crConnection.ServerName = datasource;
 crConnection.DatabaseName = "";
 crConnection.Password = password;


 AssignConnectionInfo(CrystalReportSource1.ReportDocument,crConnection);

 CrystalReportSource1.ReportDocument.DataSourceConnections[0].SetConnection 
 (crConnection.ServerName, crConnection.DatabaseName, false);

CrystalReportSource1.ReportDocument.SetDatabaseLogon(crConnection.UserID, 
crConnection.Password, crConnection.ServerName, crConnection.DatabaseName);


CrystalReportViewer1.ReportSource = CrystalReportSource1.ReportDocument;
CrystalReportViewer1.RefreshReport();

 }//close the page load function

To jest funkcja AssignConnectionInfo:

private void AssignConnectionInfo(ReportDocument document,ConnectionInfo crConnection)
    {
        foreach (CrystalDecisions.CrystalReports.Engine.Table table in document.Database.Tables)
        {
            TableLogOnInfo logOnInfo = table.LogOnInfo;
            if (logOnInfo != null)
            {
                table.ApplyLogOnInfo(table.LogOnInfo);
                table.LogOnInfo.TableName = table.Name;
                table.LogOnInfo.ConnectionInfo.UserID = crConnection.UserID;
                table.LogOnInfo.ConnectionInfo.Password = crConnection.Password;
                table.LogOnInfo.ConnectionInfo.DatabaseName = crConnection.DatabaseName;
                table.LogOnInfo.ConnectionInfo.ServerName = crConnection.ServerName;

                CrystalReportViewer1.LogOnInfo.Add(table.LogOnInfo);

            }
        }



    }

więc to, co się dzieje, to ładowanie strony i transparent Crystal, pasek narzędzi wyświetla, ale pole danych, które mam w moim raporcie, jest puste. Czy widzisz coś złego?

Bardzo dziękuję z góry

Susan

questionAnswers(2)

yourAnswerToTheQuestion