//存储过程名
string strSql = "SubPlanAndLast";
//连接字符串
string strCon = ConfigurationManager.ConnectionStrings["SqlCon"].ToString();
SqlConnection con = new SqlConnection(strCon);
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand(strSql, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@year", year);
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
CrystalReportSource1.ReportDocument.Load(Server.MapPath("Report1.rpt"));
//注意此处必需指明Dataset中的表的名称,否则会提示“您请求的报表需要更多信息.”
CrystalReportSource1.ReportDocument.SetDataSource(dt);
CrystalReportSource1.DataBind();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind();
CrystalReportViewer1.BestFitPage = true;
CrystalReportViewer1.Width = Unit.Pixel(400);