Problems opening a report from C # in Crystal Report


Working in a Windows Forms, Crystal Report 8.5, and SQL Server 2014 desktop application

To connect from CR to my database is through ODBC the strange thing is that I have a report that only use a single table and works well if I do not send parameters.

But I have a report in which I bring the data for the invoice in which I use several tables and to that query I send a parameter.

The consultation of the database is carried out without problems, but it brings me the data, for that I use a strongly typed list, the problem is apparently when the report is going to be shown, I mean the connection of the report by the next image.

The code to call the report is the following:

private void MostrarReporte()
        ParameterField pf1 = new ParameterField();
        ParameterFields pfs = new ParameterFields();
        ParameterDiscreteValue pdv1 = new ParameterDiscreteValue();

        pf1.Name = "comPagoId";
        pdv1.Value = txtComprobantePagoId.Text.Trim();

        var filePath = @"D:\ReportesPrueba\Factura.rpt";
        var factura = _saReComprobantePago.ListarFactura(Convert.ToInt32(txtComprobantePagoId.Text));
        var frm = new FrmReportes();
        frm.CrystalReportViewer.ParameterFieldInfo = pfs;
        frm.CrystalReportViewer.ReportSource = _rptListaFactura;
        var cn = new ConnectionInfo()
            ServerName = ".",
            DatabaseName = "Business",
            UserID = "lima",
            Password = "xxxx",
            Type = ConnectionInfoType.SQL
        SetDbLogonForReport(cn, _rptListaFactura);

I call this method to assign the connection data to the report.

private void SetDbLogonForReport(ConnectionInfo connectionInfo, ReportDocument rptDocument)
        Tables myTables = rptDocument.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in myTables)
            TableLogOnInfo myTableLogonInfo = myTable.LogOnInfo;
            myTableLogonInfo.ConnectionInfo = connectionInfo;

In the folder where I have the reports there is a file named logger_asserts with the following lines:

14:47:30 (6868, 9268), (1, 1, 33009),  Info: RegCreateKeyEx(System\CurrentControlSet\Services\EventLog\Application\Crystal_crw32) failed. Error code: 5 Location: Y:\silib\slib\src\registry.cpp,501 expr: 0

NOTE: With the other report that mentions you there are no problems using the same technique the difference is that it is a single table.

asked by Pedro Ávila 16.11.2018 в 13:16

0 answers