开发者

Set DataTable as DataSource for Crystal Report

I am creating a report in Visual Studio 2008. My crystal report is created using TTX or Data Definition File and I am passing a DataTable as its data source. I have already checked my TTX and DataTable columns if they are the same.

He开发者_Go百科re is the code:

string strReportFilePath = ConfigurationManager.AppSettings["ReportsPath"] + "MyReport.rpt";
rpt.Load(strReportFilePath);
DataTable dt = GetDataTableFromOracle("select item_no, descr from items");
crvReportViewer.ReportSource = rpt;
crvReportViewer.DataBind();

The result is no data on crystal report. Am I missing something? What's wrong with my code?


Adding TableName will solve this problem.

string strReportFilePath = ConfigurationManager.AppSettings["ReportsPath"] + "MyReport.rpt";
rpt.Load(strReportFilePath);
DataTable dt = GetDataTableFromOracle("select item_no, descr from items");
dt.TableName = "FileNameOfTheTTX";
crvReportViewer.ReportSource = rpt;
crvReportViewer.DataBind();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜