当前位置:网站首页>C#实现水晶报表绑定数据并实现打印
C#实现水晶报表绑定数据并实现打印
2022-06-24 23:11:00 【coder i++】
转载:https://blog.csdn.net/weixin_30340819/article/details/97184698
1.新建水晶报表并完成制作
2.
新建window窗体,并在窗体里面放置一个CrystalReportViewer控件,单击右上角的
小三角行,然后选择需要展示的报表,并设置报表的路径。
代码绑定:
string sql = “select * from tablename”;
SqlConnection conn = new SqlConnection(conn);
SqlDataAdapter da = new SqlAdapter(sql,conn);
DataSet ds = new DataSet();
CrystalReport1 cry = new CrystralReport1();
conn.Open();
da.Fill(ds,“dgv”);
cry.SetDataSource(ds.Tables[“dgv”]);
CrystalReportViewer1.ReportSource = cry;
要实现打印功能,还需要修改(这个打印功能不是CrystalReportViewer里面自带的)
//获取数据并绑定DataSet
//打印功能
PritnDocument print = new PrintDocument();
ReportDocument rd = new ReportDocument();
rd.Load(Application.StartupPath+“\CrystalReport1.rpt”);
rd.SetDatabaseLogin(“sa”,“userpwd”);
rd.SetDataSource(ds);
string printer = print.PrintSettings.PrinterName;
rd.PrintOptions.PrinterName = printer;
rd.PrintToPrinter(1,true,0,0);
边栏推荐
- Resolution of cross reference in IDA
- 数据库系统概论必背知识
- centos7.3修改mysql默认密码_详解Centos7 修改mysql指定用户的密码
- QT package the EXE file to solve the problem that "the program input point \u zdapvj cannot be located in the dynamic link library qt5cored.dll"
- Intranet learning notes (6)
- 当人们用互联网式的思维和视角来看待产业互联网的时候,其实已陷入到了死胡同
- NPM package publishing tutorial
- Charles 抓包工具
- 使用ShaderGraph制作边缘融合粒子Shader的启示
- 計網 | 【四 網絡層】知識點及例題
猜你喜欢

What are the reasons for the abnormal playback of the online channel of the channel accessed by easycvr national standard protocol?

Use of hashcat

It is said that Yijia will soon update the product line of TWS earplugs, smart watches and bracelets

Folding screen will become an important weapon for domestic mobile phones to share the apple market

高速缓存Cache详解(西电考研向)

业务与技术双向结合构建银行数据安全管理体系
![[STL source code analysis] configurator (to be supplemented)](/img/87/0ed1895e9cdb5327411c0c9cb0197f.png)
[STL source code analysis] configurator (to be supplemented)

Intranet learning notes (7)

AI clothing generation helps you complete the last step of clothing design
![[analysis of STL source code] functions and applications of six STL components (directory)](/img/f2/872fd93ef52b1424343ba634be24f6.png)
[analysis of STL source code] functions and applications of six STL components (directory)
随机推荐
文件系统 -- 磁盘基础知识和FAT32文件系统详细介绍
ProcessOn制作ER过程(自定义)
一线城市软件测试工资——你拖后腿了吗
【第26天】给定 n 个元素的升序数组nums,求实现一个函数在nums中寻找target的下标 | 初识二分查找
Internship: use of SVN
Investigation on key threats of cloud computing applications in 2022
Exploring the mystery of C language program -- C language program compilation and preprocessing
【STL源码剖析】STL六大组件功能与运用(目录)
DDD concept is complex and difficult to understand. How to design code implementation model in practice?
Of the seven levels of software testers, it is said that only 1% can achieve level 7
Is it out of reach to enter Ali as a tester? Here may be the answer you want
LINQ 查询(3)
[i.mx6ul] u-boot migration (VI) network driver modification lan8720a
LeetCode 210:课程表 II (拓扑排序)
商城项目 pc----商品详情页
Dirvish Chinese document of vim
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(2)——将数据库转换为集群模式
Planification du réseau | [quatre couches de réseau] points de connaissance et exemples
PyTorch学习笔记(七)------------------ Vision Transformer
When an interface has an exception, how do you analyze the exception?