I can not pass a parameter to my report. I have a field called Regulated, referring to the Ind Regulated field. see the code below and how do 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 started to give me an error: these were the changes:
var dv = new System.Data.DataView(dtPlanoMedico);
dv.RowFilter = "IND_REGULAMENTADO LIKE 'S'";
ReportDataSource rds = new ReportDataSource("dsDados", dv);
And that's the error:
The expression 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: \ Projects \ Services \ ReportBD.rdlc Services
What can this be?
I made this filter and filtered: dv.RowFilter = "IND_REGULAMENTADO LIKE 'N'";
, but if I do this:
dv.RowFilter = "IND_REGULAMENTADO LIKE 'N'";
dv.RowFilter = "TIPO_REGISTRO_ANS LIKE 'D'";
there only filters for the latter and not both. How do I resolve this?