如何从数据库中选择信息并将其加载到水晶报告中 [英] How to select information from database and load it into crystal report

查看:93
本文介绍了如何从数据库中选择信息并将其加载到水晶报告中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个学校管理系统。我希望用户在文本框中键入特定名称,以将学生的考试记录显示在Crystal Report中。

但是我的代码无效。



我尝试过:



尝试



Sql =select * from Student where Fullname ='& txtname.Text&'

Connect()

cmd =新的OleDbCommand(Sql,con)

dr = cmd。 ExecuteReader()



当dr.Read

CrystalReportViewer1.Rows.Add

结束时



Catch ex As Exception

结束尝试

I am creating a school management system. And I want user to type a particular name in a textbox to display the student's exams records into the Crystal Report.
But my code isn't working.

What I have tried:

Try

Sql = "select * from Student where Fullname = '" & txtname.Text &'""
Connect()
cmd = New OleDbCommand (Sql,con)
dr = cmd. ExecuteReader ()

While dr.Read
CrystalReportViewer1.Rows.Add
End while

Catch ex As Exception
End Try

推荐答案

您的代码只是添加了行CrystalReportViewer1,它不会向添加的行添加任何数据,因此您可以从数据库中为每条记录获取一个空行。
Your code just adds rows to the CrystalReportViewer1, it does not add any data to the added row so you get a blank row for each record from the database.


这篇关于如何从数据库中选择信息并将其加载到水晶报告中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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