jasperreport tableDataSource source = new jasperreport tableDataSource(SourceTalbe.TableName, SourceTalbe)这段参数怎么填

EROS Down for Maintenence
We will be back soon...
Systems, applications, and data services hosted through USGS Office of Water Information (OWI) are experiencing a service outage for hosted products at USGS EROS Data Center beginning Tuesday May 24, 2016 1 P.M. Central Time Zone.
Pending timely completion of facilities upgrades, USGS OWI hosted systems, applications, and data services are anticipated to be available as of Wednesday May 25, 2016 8 A.M. Central Time Zone.
Please contact Dane Ohe ( or 512-927-3538) or
with any questions.c# - How can I load datatable as ReportDataSource? - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
I am trying to do something like:
this.reportViewer.LocalReport.DataSources.Clear();
DataTable dt = new DataTable();
dt = this.inputValuesTableAdapter.GetData();
Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource();
rprtDTSource = // this line generates exception
//this.reportViewer.LocalReport.DataSources.Add(rprtDTSource);
this.reportViewer.RefreshReport();
How can I load datatable as ReportDataSource?
The current code produces:
"Cannot implicitly convert type 'System.Data.DataTable' to 'Microsoft.Reporting.WinForms.ReportDataSource' "
1,08031218
You are not initializing the ReportDataSouce correctly.
Give this a try:
this.reportViewer.LocalReport.DataSources.Clear();
DataTable dt = new DataTable();
dt = this.inputValuesTableAdapter.GetData();
Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource(dt.TableName, dt);
this.reportViewer.LocalReport.DataSources.Add(rprtDTSource);
this.reportViewer.RefreshReport();
Also, you might need to alter the first parameter to the ReportDataSource constructor to set the name of the datasource that your report is expecting.
I believe that madisonw's answer above is correct, but Luke's comment about using the DataSet name as named in the .rdlc report file, for the Datasource.Name property, perhaps needs to be emphasized. For me this was the main bugaboo that kept my app from working. It can be found by opening the .rdlc file as an XML file by using the "Open with..." command. The default I think is simply "DataSet1":
&DataSets&
&DataSet Name="DataSet1"&
&Field Name="BusinessEntityID"&
&DataField&BusinessEntityID&/DataField&
&rd:TypeName&System.Int32&/rd:TypeName&
One other mistake I made was not including the .rdlc file in the Debug (or Release) folder. This was fixed by right-clicking on the .rdlc file in Solution Explorer, then Properties, then setting "Copy to Output Directory" to "Copy Always".
Once these two parts were corrected my program worked to use ReportViewer within a console app to generate a PDF file with no interface.
this.reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.Reset();
reportViewer1.LocalReport.ReportEmbeddedResource = "Your Report Name.rdlc";
SqlConnection con = new SqlConnection();
con.ConnectionString = "Connection";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection =
mandType = CommandType.T
mandText = "Select * from YourTableName";
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());
con.Close();
ReportDataSource rprtDTSource= new ReportDataSource();
rprtDTSource.Name = "reportDataSetName";
rprtDTSource.Value =
this.reportViewer1.LocalReport.DataSources.Add(rprtDTSource);
this.reportViewer1.RefreshReport();
Imagine the DataSources block of your RDLC file is like below:
& DataSets >
& DataSet Name="DataSet1_Lot" >
then the relative code should be:
string name = "DataSet1_Lot"; // this must exist in the RDLC file
DataTable dt = new DataTable();
Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource(name, dt);
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
The week's top questions and answers
Important community announcements
Questions that need answers
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabled本人在闲暇之余帮朋友做了个软件,是关于考古方面的。先上图,
界面效果一般般,能过的去就行了,今天我主要说的是RDLC开发过程中容易出错的地方,我这里封装了一个RDLC调用方法:
/// &summary&
/// RDLC报表打印类
/// &/summary&
public class RDLCReportHelper
public static
ReportDataSource reportDataSource = null;
public static BindingSource bindingSource = null;
/// &summary&
/// 展示报表
/// &/summary&
/// &param name="rv"&展示报表的容器&/param&
/// &param name="ds"&数据集&/param&
/// &param name="p_strTableName"&数据集表名&/param&
/// &param name="p_strReportFile"&报表名称[路径]&/param&
public static void showReport(ReportViewer rv, DataSet ds, string p_strTableName, string p_strReportFile)
rv.Reset();
// rv.RefreshReport();
bindingSource = new BindingSource();
bindingSource.DataSource =
bindingSource.DataMember = p_strTableN
//实例化报表数据源
reportDataSource = new ReportDataSource();
//数据源名称[数据集名_表名]
reportDataSource.Name = ds.DataSetName + "_" + p_strTableN
//封装绑定的数据集给报表数据源
reportDataSource.Value = bindingS
//加载报表数据源
rv.LocalReport.DataSources.Clear();
rv.LocalReport.DataSources.Add(reportDataSource);
//指向本地报表
//rv.LocalReport.ReportEmbeddedResource = p_strReportF
rv.LocalReport.ReportPath = Application.StartupPath+"\\"+p_strReportF
rv.SetDisplayMode(DisplayMode.PrintLayout);
rv.ZoomMode = ZoomMode.P
//显示[刷新]报表数据
rv.RefreshReport();
bindingSource = null;
reportDataSource = null;
catch (Exception ex)
1、代码中的rv.reset();这句话 很重要 ,如果没有这一句话,动态切换显示不同的报表的时候,会出错。
2、rv.localReport.reportPath=......& 这里面要给reportView传递全路径的rdlc文件,否则会找不到相应的rdlc文件而报错。
3、在调试rdlc报表的时候报检测到&PInvokeStackImbalanceMessage:&对&PInvoke&函数&mon!Microsoft.ReportingServices.positionPDF+WindowsGDIWrapper::GetGlyphIndicesW&的调用导致堆栈不对称。 这种错误,但是在发布之后的程序是没有问题的,这种错误可以不用理会。
4、调用方法如下:
ds = new DataSet();
String whereS
if (this.cbType.Text == "器材列表") {
ds = b_device.getDataSetDevice();
ds.DataSetName = "DataSet_device";
ds.Tables[0].TableName = "device";
Utils.RDLCReportHelper.showReport(this.reportViewer1, ds, "device", "RDLC\\Report_qicai.rdlc");
我说的只是对rdlc使用过程中容易出现的问题,本人也是对rdlc第一次使用,希望和大家一起交流,共同进步。&&& 到此为止& thanks
阅读(...) 评论() &}

我要回帖

更多关于 crystalreportsource 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信