将DataTable设置为Crystal Report的数据源 [英] Set DataTable as DataSource for Crystal Report

查看:68
本文介绍了将DataTable设置为Crystal Report的数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio 2008中创建一个报表。我的水晶报表是使用TTX或数据定义文件创建的,并且正在传递DataTable作为其数据源。我已经检查了我的TTX和DataTable列是否相同。

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.

这是代码:

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

结果在Crystal报表上没有数据。我想念什么吗?我的代码有什么问题?

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

推荐答案

添加TableName将解决此问题。

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();

这篇关于将DataTable设置为Crystal Report的数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆