当前位置:网站首页>C # realizes crystal report binding data and printing
C # realizes crystal report binding data and printing
2022-06-25 02:40:00 【coder i++】
Reprint :https://blog.csdn.net/weixin_30340819/article/details/97184698
1. Create a new crystal report and complete the production
2.
newly build window forms , And put a... In the form CrystalReportViewer Control , Click on the
Small triangle row , Then select the report to be displayed , And set the path of the report .
Code binding :
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;
To realize the printing function , It needs to be revised ( This print function is not CrystalReportViewer It comes with )
// Get data and bind DataSet
// Printing function
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);
边栏推荐
- AI服装生成,帮你完成服装设计的最后一步
- Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (2) -- convert database to cluster mode
- 1-6搭建Win7虚拟机环境
- Pytorch learning notes (VII) ------------------ vision transformer
- Leecode learning notes - the shortest path for a robot to reach its destination
- Post competition summary of kaggle patent matching competition
- Leetcode 210: curriculum II (topological sorting)
- 常用的软件测试工具清单,请查收。
- ida中交叉引用的解析
- Talking about the advantages of flying book in development work | community essay solicitation
猜你喜欢

做软件安全测试的作用,如何寻找软件安全测试公司出具报告?

Sumati gamefi ecological overview, element design in the magical world

Pytorch learning notes (VII) ------------------ vision transformer

Pit entry machine learning: I. Introduction

Once beego failed to find bee after passing the go get command Exe's pit

分布式事务解决方案和代码落地

Are programmers from Huawei, Alibaba and other large manufacturers really easy to find?

Distributed transaction solutions and code implementation

Processon producer process (customized)

Intranet learning notes (7)
随机推荐
Groovy之高级用法
Four characteristics of actual attack and defense drill
E - average and median
转行软件测试2年了,给还在犹豫的女生一点建议
Mall project pc--- product details page
Jetson nano from introduction to practice (cases: opencv configuration, face detection, QR code detection)
业务与技术双向结合构建银行数据安全管理体系
一线城市软件测试工资——你拖后腿了吗
[I.MX6UL] U-Boot移植(六) 网络驱动修改 LAN8720A
Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (3) -- set the database to archive mode
Application of TSDB in civil aircraft industry
保险APP适老化服务评测分析2022第06期
给你讲懂 MVCC 续篇
中信证券手机开户是靠谱的吗?安全吗
李宏毅《机器学习》丨6. Convolutional Neural Network(卷积神经网络)
LeetCode 210:课程表 II (拓扑排序)
Pytorch learning notes (VII) ------------------ vision transformer
Lizuofan, co-founder of nonconvex: Taking quantification as his lifelong career
DDD concept is complex and difficult to understand. How to design code implementation model in practice?
Random list random generation of non repeating numbers