下午好開發商, 這是我的函數生成的水晶報表,這將需要的報表名稱和ReportQuery作爲輸入參數,並會生成一個數據集,有了這個數據集我怎樣才能設計我的報告?因爲這是在運行時生成的,我怎麼能訪問到生成我ReportDesign?如何設計Crystal報表與動態數據
public void fnLoadDataToReport(string rptName, string rptQuery)
{
try
{
DataSet myDS=new DataSet();
// crReportDocument.Load(Server.MapPath("Reports\" & RptName), OpenReportMethod.OpenReportByTempCopy);
crReportDocument.Load(Server.MapPath("Reports\\" + rptName));
SqlConnection myConnection=new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
SqlCommand myCommand=new SqlCommand(rptQuery,myConnection);
SqlDataAdapter MyDA=new SqlDataAdapter(myCommand);
MyDA.Fill(myDS,"ReportTable");
crReportDocument.SetDataSource(myDS);
crvReportGeneration.ReportSource=crReportDocument;
crvReportGeneration.ShowFirstPage();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
任何幫助是可觀的....!
嘗試使用using語句封裝SqlConnection,SqlCommand和SqlDataAdapter - http://msdn.microsoft.com/en-us/library/yh598w02.aspx – 2012-04-10 07:39:23
封裝的用途是什麼?那之後該怎麼辦? – 2012-04-10 08:33:07