首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >来自数据集的Vb.Net水晶报告

来自数据集的Vb.Net水晶报告
EN

Stack Overflow用户
提问于 2013-12-30 04:05:45
回答 1查看 11.4K关注 0票数 0

我正在使用Vb.Net 2010来开发具有水晶报表的项目。我连接到sqlserver并使用函数Adapter.Fill( dataset,"tableName")填充我的数据集。我现在关心的是如何在水晶报表中显示我的数据集或数据表中的数据?

EN

回答 1

Stack Overflow用户

发布于 2014-05-14 16:18:12

这里我的代码使用了两个表authors和tables

代码语言:javascript
复制
'Build a SQL statement to query for the authors table 

Dim sqlString As String = "SELECT * FROM authors"

'Retrieve the data using the SQL statement 

adoOleDbDataAdapter = New OleDbDataAdapter(sqlString, adoOleDbConnection)

'Build a SQL statement to query for the titleauthor table 

sqlString = "SELECT * FROM titleauthor" 

'Retrieve the data using the SQL statement 

adoOleDbDataAdapter2 = New OleDbDataAdapter(sqlString, adoOleDbConnection) 

'Create a instance of a Dataset 

DataSet1 = New DataSet() 

'Fill the dataset with the data with author information 

adoOleDbDataAdapter.Fill(DataSet1, "authors") 

'Fill the dataset with the data with titleauthor information. 
'The table name used in the Fill method must be identical to the name 
'of the table in the report. 

adoOleDbDataAdapter2.Fill(DataSet1, "titleauthor") 

'Pass the dataset to the report   YOU NEED THIS

Dim crReportDocument As New CrystalReport1()


crReportDocument.Database.Tables(0).SetDataSource(DataSet1) 

'View the report 

CrystalReportViewer1.ReportSource = crReportDocument

请记住您需要导入

导入CrystalDecisions.CrystalReports.Engine导入CrystalDecisions.Shared

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20829545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档