2014-06-09 1 views
0

에 매개 변수를 전달하고 reportViewer.C#을 보고서는 프로그래밍 방식으로 사용하여 다음 표시되는</p> <p>은 내가해야하는 보고서에 전달 될 필요가 GUID 목록입니다 ... 내가 이것을 알아 내기 위해 시도 며칠 보냈다의 ReportViewer

guids와 함께 쉼표로 구분 된 목록을 어셈블 할 수 있습니다 ... 그러나 매개 변수를 보고서에 전달하는 방법을 모르겠습니다. 보고서의 작곡가는 쉼표로 구분 된 GUID 목록을 전달해야한다고 말했습니다.

보고서를 만들지 않았으며 해당 구성에 직접 액세스 할 수 없습니다. (직접 액세스해야합니까? 그것?)

private void getreport_Click(object sender, EventArgs e) 
{ 

     //May/20/14 (02:07PM) [AST] - Bootty ton for getting the new RDL report. 
    outputBox.Clear(); 
    reportViewer.Show(); 

    reportViewer.ServerReport.ReportServerUrl = new Uri("http://prdukhscasq01/reportserver"); 
    //reportViewer.ServerReport.ReportServerCredentials.ImpersonationUser = WindowsIdentity.GetCurrent(); 
    //reportViewer.ServerReport.ReportPath = "/Charge Reconciliation/Combined Charge Report"; 
    reportViewer.ServerReport.ReportPath = "Scheduled Reports/HandOver/UK_HandOver_RoundingReport"; 



    //May/20/14 (04:14PM) [AST] - Must manually declare the reporting type because Obj+ contains its own report params 
    // Dynamically creates a container for the paramerter to be passed to the report. 

    int additional_params = 1; 
    string patients_guids = ""; 

     // Counter for keeping track of where we are in the rows to inject the params 
    int count = 0 + additional_params; 

    Microsoft.Reporting.WinForms.ReportParameter[] yourParams 
     = new Microsoft.Reporting.WinForms.ReportParameter[dataGridViewPatients.RowCount+additional_params]; 

     // additional peramiters can be added here. you must add to the counter for each param in order for thet count to be correnct in the for each loop 


     // Grabs current context to allow pulling of data from current session 
    //CustomContextObj cc = CustomContextObj.GetInstance(); 

     //Param #1 logge in user guid 


    //** need to create a DB connection using Current connection find this in the CV3ClientVisit table. 


    foreach (Patient p in getSelectedPatients().Value) 
    { 
     patients_guids += p.VisitGUID + "'"; 
     MessageBox.Show(p.VisitGUID); 
    } 

// yourParams[0] = new Microsoft.Reporting.WinForms.ReportParameter("User_Guid",cc.UserGUID.ToString()) 
       // goes threw all of the names populated to the list 
    /* foreach (DataGridViewRow row in dataGridViewPatients.Rows) 
    { 
      //keeps our current position in check 


     yourParams[count] = 
      new Microsoft.Reporting.WinForms.ReportParameter(row.Cells[0].Value.ToString(),row.Cells[1].Value.ToString()); 

     MessageBox.Show(row.Cells[0].Value.ToString()+ "," +row.Cells[1].Value.ToString()); 

     ++count; 

    }*/ 



    // EX.. yourParams[0] = new Microsoft.Reporting.WinForms.ReportParameter("Employe", "data");//Adjust value 




     // Completed Refresh 
    reportViewer.RefreshReport(); 
} 

나는이 RDL 보고서 물건에 아주 새로운 해요 및 나의 무지에 대해 사과 ... 어떤 도움을 크게 감상 할 수있다.

+0

다음을 추가해야 할 수 있습니다. ReportViewer.ServerReport.SetParameters (yourParams); 목록을 매개 변수로 전달해야합니까? 나는 RDLC를 사용했고 그 안에서 우리는 데이터 소스로서리스트를 직접 전달할 수있다. – aaa

+0

고마워요. 내가 뭘 알아 냈는지. 거기에 하나의 매개 변수가 나는 그것을 던지고 예외가 ... 어떤 잡을 수없는 ... 확실하지 왜 그 ...하지만 지금은 절반 방법. –

답변

0

일부 검색 및 마감과 함께 나는 대답을 생각해 냈습니다.

매개 변수는 보고서의 이름과 정확하게 일치해야합니다.

GUIDstring은 보고서 매개 변수 중 하나의 이름입니다.

private void getreport_Click(object sender, EventArgs e) 

    { 



      //May/20/14 (02:07PM) [AST] - Bootty ton for getting the new RDL report. 

     outputBox.Clear(); 

     reportViewer.Show(); 



     reportViewer.ServerReport.ReportServerUrl = new Uri("http://prdukhscasq01/reportserver"); 

     //reportViewer.ServerReport.ReportServerCredentials.ImpersonationUser = WindowsIdentity.GetCurrent(); 

     //reportViewer.ServerReport.ReportPath = "/Charge Reconciliation/Combined Charge Report"; 

     reportViewer.ServerReport.ReportPath = "/Scheduled Reports/HandOver/UK_HandOver_RoundingReport"; 

     //          Scheduled Reports/HandOver/UK_HandOver_RoundingReport 





     //May/20/14 (04:14PM) [AST] - Must manually declare the reporting type because Obj+ contains its own report params 



     string patients_guids = ""; 







     foreach (Patient p in getSelectedPatients().Value) 

     { 

      patients_guids += p.VisitGUID + ","; 



     } 





     // Assembles the parameter to pass guids. Matching that of the report. 

     Microsoft.Reporting.WinForms.ReportParameter patient_guids_param = 

      new Microsoft.Reporting.WinForms.ReportParameter("GUIDstring", patients_guids); 



     reportViewer.ServerReport.SetParameters(patient_guids_param); 





      // Completed Refresh 

     reportViewer.RefreshReport(); 

    }