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();
pf1.CurrentValues.Add(pdv1);
pfs.Add(pf1);
var filePath = @"D:\ReportesPrueba\Factura.rpt";
_rptListaFactura.Load(filePath);
var factura = _saReComprobantePago.ListarFactura(Convert.ToInt32(txtComprobantePagoId.Text));
_rptListaFactura.SetDataSource(factura);
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);
frm.CrystalReportViewer.Refresh();
frm.Show();
}
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;
myTable.ApplyLogOnInfo(myTableLogonInfo);
}
}
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.