1
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'DataSet1.sp_GetRent1' table. You can move, or remove it, as needed.
this.sp_GetRent1TableAdapter.Fill(this.DataSet1.sp_GetRent1, "@RentNo1", "@AppPath");
//this.GetSPResult();
this.reportViewer1.RefreshReport();
}
private void button1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
reportViewer1.Visible = true;
reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1",dt));
GetSPResult();
}
private DataTable GetSPResult()
{
DataTable ResultsTable = new DataTable();
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=RentACar1;Integrated Security=True");// ProviderName = "System.Data.SqlClient");
try
{
SqlCommand cmd = new SqlCommand("sp_GetRent1",conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@RentNo1", "9905-10-2017");
cmd.Parameters.AddWithValue("@AppPath", @"E:\Rent A Car\RentACar1\RentACar\bin\Debug");
conn.Open();
//cmd.ExecuteNonQuery();
SqlDataAdapter adaptor = new SqlDataAdapter(cmd);
adaptor.SelectCommand = cmd;
adaptor.Fill(ResultsTable);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return ResultsTable;
}
이 코드는 RDLC 보고서에 아무 것도 표시하지 않습니다. dataset1.xsd를 열고 SP에 동일한 매개 변수를 지정하면 그리드에 값이 표시됩니다. 그러나 나는 RDLC에서 가치를 얻을 수 없다.2 매개 변수가있는 RDLC 보고서 (저장 프로 시저)
왜 그렇습니까? 보고서에 빈 테이블을 제공하고 데이터를 아직 _another_ 테이블로 가져 오는 메소드를 _then_ 호출합니다. – DonBoitnott
코드로 나를 도울 수 있습니까? –