如何使用sql server 2005在vb.net中创建水晶报表 [英] How to create crystal report in vb.net using sql server 2005

查看:60
本文介绍了如何使用sql server 2005在vb.net中创建水晶报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展一个项目...需要在水晶报告上显示报告...






有人可以告诉我表格中用于报告路径的字符串吗?

解决方案

好了现在让我直截了当你需要加载一些报告你好,我的朋友,她为你做了什么



一旦你配置了你的水晶报告你所要做的就是采取另一种形式拖放现在你必须配置你的水晶报告查看器以查看所需的报告,因为该水晶报告查看器组件有一个称为报告源的属性,一旦你点击它它会给你一套报告你的在你的应用程序中选择所需的报告和你做的。



现在你必须有一个问题,配置报告显示好我的朋友水晶报告组件完成所有这些本身并不担心设置和al只有当你根据自己的要求设计和配置报告时,水晶报告才能正常工作,否则你也可以将水晶报告转换成PDF格式如果报告转换成PDF格式后你仍然对水晶报告有疑问你可以在COM组件的帮助下轻松显示PDF文件用于将水晶报表转换为pdf的两个名称空间是

  Imports  CrystalDecisions.CrystalReports.Engine 
Imports CrystalDecisions。 Shared





和她的链接将引导你将水晶报告转换成PDF格式

CRYSTAL REPORT成PDF格式 [ ^ ]



在上面的链接中你会遇到一行代码,上面写着

 cryRpt.Load(PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt <跨度类= 代码串>  <跨度类= 代码串>);  



没有什么可担心的只是添加你的水晶报告的路径例如说你的水晶报告在D驱动器中名为negi的文件夹和nae你的报告是Myreport.rpt所以你可以修改代码并写上



 cryRpt.Load(@   D:\ negi\Myreport.rpt); 



多数民众赞成



请记住上面的代码是在C#中我觉得你可以很容易地把它转换成VB.NET



请在发现有用后给我的答案评分

谢谢&问候

Radix:rose:


嗨试试这个代码我使用和这项工作Nicelly



但是



首先你在表格列名中创建一个数据集和数据集列相同的名称(区分大小写)



然后



在数据中插入数据集列报表设计



然后

从Crystal中获取数据并在Crystal Report中加载数据集后加载数据集。



Dim report As CrystalReportName = New CrystalReportName

Dim sReader As SqlDataReader

Dim dataT As New DataTable



cmd.commandTex =你的SQL查询在这里



sReader = cmd.ExecuteReader

dataT.Load(sReader)



report.SetDataSource(dataT )



CrystalReportViewerName.ReportSource =报告

CrystalReportViewerName.Refresh()

你好

您可以添加通过单击解决方案资源管理器然后选择AddNewItem并选择Crystal Report,Crystal Report将在您的项目中获得一个水晶报告,但在此之前它会显示一个水晶报告库,从他们选择您想要的报告类型然后转到字段资源管理器窗口和选择数据库字段选项右键单击它并选择数据库专家选项,然后从他们的转到

创建新连接>> OLE DB(ADO)并选择你的数据库说如果你使用sql选择Microsoft OLE DB提供程序为SQL服务器选择你的表单击下一步然后完成然后你准备好去



一旦发现它有用,请评价我的答案



谢谢和问候

基数:玫瑰:


I am working on a project ...need to show report ... on crystal report.



can some one tell me the string used for report path in the form?

解决方案

ok now let me get this straight u need to load some report of urs right well my friend hers what u have to do for that

once u have configured ur crystal report all u have to do is take another form drag and drop a crystal report viewer on that form now u have to configure ur crystal report viewer for the viewing of the desired report, for that crystal report viewer component has a property called as Report Source once u click on it it will give u a set of report which u have in ur application select the desired report and ur done.

Now u must have a question for configuring the report for display well my friend crystal report component does all that by itself and dont worry at all regarding the setup and all crystal report will work fine if and only if u have designed and configured the report as per ur requirements otherwise u can also convert the crystal report into PDF format if ur still having doubt regarding crystal report once the report is converted into PDF format u can easily dispaly the PDF file with the help of a COM component the two namespaces for converting crystal report to pdf are

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared



and hers the link that will guide u in converting a crystal report into PDF format
CRYSTAL REPORT INTO PDF FORMAT[^]

in the above link u will come across a line of code which says

cryRpt.Load(PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt");


well nothing to worry about just add in the path where ur crystal report is for example say ur crystal report is in D drive in a folder called negi and the nae of ur report is Myreport.rpt so u can modify the code and write

cryRpt.Load(@"D:\negi\Myreport.rpt");


thats it

Remember the above code is in C# i feel u can easily convert it into VB.NET

Please Rate my answer once u find it useful
Thanks & Regards
Radix :rose:


hi try this code I use and this work Nicelly

but

first u create a one data set and dataset column same name in table column name(case sensitive)

then

Insert Dataset column in your crystal Report Design

then
Get data from Table and load in dataset there after data set load in Crystal Report.

Dim report As CrystalReportName= New CrystalReportName
Dim sReader As SqlDataReader
Dim dataT As New DataTable

cmd.commandTex="Your Sql Query Here"

sReader = cmd.ExecuteReader
dataT.Load(sReader)

report.SetDataSource(dataT)

CrystalReportViewerName.ReportSource = report
CrystalReportViewerName.Refresh()


Hello
You can add Crystal Report by clicking in the solution explorer and then selecting AddNewItem and thn select Crystal Report u will get a crystal report in your project but before that it will show you a crystal report gallery from their select the type of report you want and then go to the field explorer window and select database field option right click it and select database expert option and from their go to
Create new connection>> OLE DB(ADO)and select your database say if ur working with sql select Microsoft OLE DB provider for SQL server select your table click on next and then finish and then you are ready to go

Do rate my answer once u find it useful

Thanks & Regards
Radix :rose:


这篇关于如何使用sql server 2005在vb.net中创建水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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