Difficulty in passing a parameter to a rdlc I have (Oracle)

Asked

Viewed 507 times

1

I am unable to pass a parameter to my report. I have a field called Regulated, referring to the Ind_regulated field. see the code below and how I make this filter?

public static void Emitir()
        {           
            //Relatório com DataSource = ORACLE
            dsPlanoMedico.PLANO_MEDICODataTable dtPlanoMedico = new dsPlanoMedico.PLANO_MEDICODataTable();
            dsPlanoMedicoTableAdapters.PLANO_MEDICOTableAdapter adapt = new dsPlanoMedicoTableAdapters.PLANO_MEDICOTableAdapter();

            adapt.Fill(dtPlanoMedico);
            dtPlanoMedico.Where(i => i.IND_REGULAMENTADO == "S");//aqui não funciona

            ReportDataSource rds = new ReportDataSource("dsDados", dtPlanoMedico.DefaultView);
            ReportViewer viewer = new ReportViewer();

            viewer.ProcessingMode = ProcessingMode.Local;
            viewer.LocalReport.ReportPath = "ReportBD.rdlc";
            //viewer.LocalReport.SetParameters(new ReportParameter("Regulamentado", "S"));
            viewer.LocalReport.DataSources.Add(rds);

            Warning[] warnings;
            string[] streamIds;
            string mimeType = string.Empty;
            string encoding = string.Empty;
            string extension = string.Empty;

            byte[] bytesPDF = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
            FileStream fsPDF = new FileStream("c:\\temp\\report.pdf", FileMode.Create);
            fsPDF.Write(bytesPDF, 0, bytesPDF.Length);
            fsPDF.Close();
            fsPDF.Dispose();

            byte[] bytesExcel = viewer.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
            FileStream fsExcel = new FileStream("c:\\temp\\report.xls", FileMode.Create);
            fsExcel.Write(bytesExcel, 0, bytesExcel.Length);
            fsExcel.Close();
            fsExcel.Dispose();

            byte[] bytesWord = viewer.LocalReport.Render("Word", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
            FileStream fsWord = new FileStream("c:\\temp\\report.doc", FileMode.Create);
            fsWord.Write(bytesWord, 0, bytesWord.Length);
            fsWord.Close();
            fsWord.Dispose();


        }

I went to make some changes and it started to give me a mistake: those were the amendments:

var dv = new System.Data.DataView(dtPlanoMedico);
            dv.RowFilter = "IND_REGULAMENTADO LIKE 'S'";

            ReportDataSource rds = new ReportDataSource("dsDados", dv);

And that’s the mistake:

The Value Expression for the text box ːCOD_PLANO' refers to the field COD_PLANO'. Report item Expressions can only refer to Fields Within the Current dataset Scope or, if Inside an Aggregate, the specified dataset Scope. Letters in the Names of Fields must use the correct case. C: Services Projects Reportbd.rdlc Services

What can it be?

I made this filter and filtered: dv.RowFilter = "IND_REGULAMENTADO LIKE 'N'";, but if I do so:

dv.RowFilter = "IND_REGULAMENTADO LIKE 'N'"; 
dv.RowFilter = "TIPO_REGISTRO_ANS LIKE 'D'"; 

then only filter for the last and not both. How do I solve this?

1 answer

1

I resolved so:

public static void Emitir()
        {
            //Relatório com DataSource = ORACLE
            dsPlanoMedico.PLANO_MEDICODataTable dtPlanoMedico = new dsPlanoMedico.PLANO_MEDICODataTable();
            dsPlanoMedicoTableAdapters.PLANO_MEDICOTableAdapter adapt = new dsPlanoMedicoTableAdapters.PLANO_MEDICOTableAdapter();

            adapt.Fill(dtPlanoMedico);
            //dtPlanoMedico.Where(i => i.IND_REGULAMENTADO == "S");

            var dv = new System.Data.DataView(dtPlanoMedico);//aqui
            dv.RowFilter = "IND_REGULAMENTADO LIKE 'N' and TIPO_REGISTRO_ANS LIKE 'D'";//aqui

            ReportDataSource rds = new ReportDataSource("dsDados", dv);//aqui
            ReportViewer viewer = new ReportViewer();

            viewer.ProcessingMode = ProcessingMode.Local;
            viewer.LocalReport.ReportPath = "ReportBD.rdlc";
            //viewer.LocalReport.SetParameters(new ReportParameter("Regulamentado", "S"));
            viewer.LocalReport.DataSources.Add(rds);

            Warning[] warnings;
            string[] streamIds;
            string mimeType = string.Empty;
            string encoding = string.Empty;
            string extension = string.Empty;

            byte[] bytesPDF = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
            FileStream fsPDF = new FileStream("c:\\temp\\report.pdf", FileMode.Create);
            fsPDF.Write(bytesPDF, 0, bytesPDF.Length);
            fsPDF.Close();
            fsPDF.Dispose();

            byte[] bytesExcel = viewer.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
            FileStream fsExcel = new FileStream("c:\\temp\\report.xls", FileMode.Create);
            fsExcel.Write(bytesExcel, 0, bytesExcel.Length);
            fsExcel.Close();
            fsExcel.Dispose();

            byte[] bytesWord = viewer.LocalReport.Render("Word", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
            FileStream fsWord = new FileStream("c:\\temp\\report.doc", FileMode.Create);
            fsWord.Write(bytesWord, 0, bytesWord.Length);
            fsWord.Close();
            fsWord.Dispose();


        }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.