我做了一个小程序,用来显示日文单词的报表,但生成的报表只显示字段名,下面的都是空白。程序如下:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Collections;
using Microsoft.Reporting.WinForms;
namespace 日语单词背诵系统
{
public partial class Report : Form
{
RDSet RepoSet = new RDSet();
DataTable mwords = new DataTable(); public Report()
{
InitializeComponent();
reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
} private void Report_Load(object sender, EventArgs e)
{
string str = "select 平假名,汉字,释义,例句 from 单词总表 where 录入日期 ='2009年3月23日';";
Getdata(str);
this.reportViewer1.RefreshReport(); }
private void Getdata(string sqlString)
{
try
{ Conn conn = new Conn();
OleDbConnection connection = conn.CreatConn();
connection.Open();
OleDbDataAdapter myAda = new OleDbDataAdapter(sqlString, connection);
//myAda.Fill(mwords); myAda.Fill(RepoSet, "RDTable");
mwords = RepoSet.Tables["RDTable"]; connection.Close(); reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";
ReportDataSource rds = new ReportDataSource("RDSet_RDTable", mwords);
//rds.Name = "RDTable"; //rds.Value = mwords;
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.RefreshReport();
}
catch
{
MessageBox.Show("检查数据库联接!");
return;
}
} }
}我用的是vs2008,在项目中添加了数据集RDSet,内有表RDTable(平假名,汉字,释义,例句)报表用reportview,直接从数据源中拖的,调试时显示rds中已经有内容,但报表中只显示字段就不显示内容。恳请各位高手给予指点,感谢!
刚才发现调试输出warning:Warning: 数据集“RDSet_RDTable”包含 Field“jiaming”的定义。从数据源返回的结果集中缺少该字段。 (rsMissingFieldInDataSet)
Warning: 数据集“RDSet_RDTable”包含 Field“jiaming”的定义。数据扩展插件在读取字段时返回了错误。位置 1 处的字段没有数据。 (rsErrorReadingDataSetField)字段1~4都有,这里省略。我设置的数据源字段名开始是用拼音,后来改成汉字。有关吗?请教大家如何修改?
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Collections;
using Microsoft.Reporting.WinForms;
namespace 日语单词背诵系统
{
public partial class Report : Form
{
RDSet RepoSet = new RDSet();
DataTable mwords = new DataTable(); public Report()
{
InitializeComponent();
reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
} private void Report_Load(object sender, EventArgs e)
{
string str = "select 平假名,汉字,释义,例句 from 单词总表 where 录入日期 ='2009年3月23日';";
Getdata(str);
this.reportViewer1.RefreshReport(); }
private void Getdata(string sqlString)
{
try
{ Conn conn = new Conn();
OleDbConnection connection = conn.CreatConn();
connection.Open();
OleDbDataAdapter myAda = new OleDbDataAdapter(sqlString, connection);
//myAda.Fill(mwords); myAda.Fill(RepoSet, "RDTable");
mwords = RepoSet.Tables["RDTable"]; connection.Close(); reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";
ReportDataSource rds = new ReportDataSource("RDSet_RDTable", mwords);
//rds.Name = "RDTable"; //rds.Value = mwords;
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.RefreshReport();
}
catch
{
MessageBox.Show("检查数据库联接!");
return;
}
} }
}我用的是vs2008,在项目中添加了数据集RDSet,内有表RDTable(平假名,汉字,释义,例句)报表用reportview,直接从数据源中拖的,调试时显示rds中已经有内容,但报表中只显示字段就不显示内容。恳请各位高手给予指点,感谢!
刚才发现调试输出warning:Warning: 数据集“RDSet_RDTable”包含 Field“jiaming”的定义。从数据源返回的结果集中缺少该字段。 (rsMissingFieldInDataSet)
Warning: 数据集“RDSet_RDTable”包含 Field“jiaming”的定义。数据扩展插件在读取字段时返回了错误。位置 1 处的字段没有数据。 (rsErrorReadingDataSetField)字段1~4都有,这里省略。我设置的数据源字段名开始是用拼音,后来改成汉字。有关吗?请教大家如何修改?
解决方案 »
- C#读取EXCEL内容到类时遇到的问题
- DialogResult
- com组件接口问题
- 让gridview绑定的一个字段(comname)为“沃尔玛”的行显示其他颜色的问题
- 如何实现基于DirectX.Capture.DLL的视频监控的全屏显示
- 求正则表达式。。如何匹配<AAA id="main" head="test" yyy="test"....title="8888">
- c# checkbox 显示问题!
- 怎样用同一台机子上的两个不同 IP 的同一个端口号进行通讯。
- 新手问题怎样将stu_date.text转换成DateTime类型(在线等)
- 去掉任务栏右键关闭程序
- C# OA 传递消息
- 看谁能帮我解释一下这段代码
然后保证这个DataTable和你在程序中取出的数据格式一致就好了。
至于有空页的问题,建议查一查你的报表的大小以及页边距,你也可以搜一搜以前的帖子,关于rdlc,空白打印页的问题。如果不是这个问题,你可以忽略我的回答。