Pundia 0 Newbie Poster

Hello! I'm trying to fill a Crystal Reports in a generic way. This is because I don't have direct access to the database, I just call a service that returns a DataTable. I'm no expert in C# or Crystal Reports, is there any way to fill a Crystal report without knowing the columns I'm receiving?

This is what I've tried so far:

dt = new DataTable();
dt = getData();
var rpt = new ReportDocument();
rpt.Load(@"CrystalReport1.rpt");
rpt.SetDataSource(dt);

crystalReportViewer1.ReportSource = rpt;
var paramFields = new ParameterFields();
var paramField = new ParameterField {Name = "col1"};
var paramDiscreteValue = new ParameterDiscreteValue {Value = "Descripcion"};
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);

crystalReportViewer1.ParameterFieldInfo = paramFields;
crystalReportViewer1.Show();

this.Refresh();

I tried paramFields because nothing appeared on the report. Still, the report doesn't show anything. It shows the column name of one of the fields as Details, like in this screenshot.

Please, what am I missing? Thanks in advance!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.