将数据集中的2个不同数据表中的值传递给Crystal报表时出现问题 [英] Problem in passing values from 2 different datatables in a dataset to Crystal report
本文介绍了将数据集中的2个不同数据表中的值传递给Crystal报表时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个包含2个数据表"Load_image","Load_Word"的数据集.我正在尝试将它们设置为Crystal报表的数据源,并且数据没有传递到各个字段.
当我仅传递一个dataTable时,Crystal Report上将填充数据.我也包含了代码.
Hello All,
I have a dataset with 2 datatables "Load_image", "Load_Word". I am trying to set them up as data source to crystal reports and data is not passing to respective fields.
When I am passing only one dataTable, Data Populates on Crystal Report. I am including the code also.
Public Sub Preview_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cryRpt As New PreviewReport
Dim sample As New DataSet
Dim FS As FileStream
Dim DTImage As New DataTable("Load_Image")
Dim DTText As New DataTable("Load_Word")
Dim IRow As DataRow
DTImage.Columns.Add("HeaderImage", System.Type.GetType("System.Byte[]"))
IRow = DTImage.NewRow
Dim IR As BinaryReader
cryRpt.Load("F:\Projects\2008 Projects\VB.NET\Print from wordpad\Print from wordpad\PreviewReport2.rpt")
FS = New FileStream(Load_MS_Word.getfilepath, FileMode.Open)
IR = New BinaryReader(FS)
Dim imgbyte(FS.Length) As Byte
imgbyte = IR.ReadBytes(Convert.ToInt32((FS.Length)))
IRow(0) = imgbyte
DTImage.Rows.Add(IRow)
sample.Clear()
sample.Tables.Add(DTImage)
sample.Tables.Add(DTText)
IR.Close()
FS.Close()
DTText.Columns.Add("RTFText", GetType(String))
DTText.Rows.Add(Picture)
cryRpt.SetDataSource(sample)
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
End Sub
表"Load_image"和"Load_word"中的列已经在晶体报表中.
请帮助我.
The Columns from Tables "Load_image" and "Load_word" are already on the crystal report.
Please help me in this.
推荐答案
对,为此,您有2个选择
1.尝试使两个表成为单个表
2.放置一个数据集/数据表,手动定义列,然后分配值,然后将其分配给Crystal报表.
如果您有任何疑问可以答复我...
ya, for this u have 2 options
1. try to make two tables as single
2. put one dataset/datatable, define the columns manually then assign the values then assign it to crystal report.
if u hav any doubts reply me...
我发现我从第二个函数传递过来的第二个表与第一个函数重叠.因此,我在代码中创建了2个新表,然后进行了尝试.
I figured out that the second table that I am passing on from second function is overlapping the first one. So I created 2 new tables in code and then tried and it worked.
这篇关于将数据集中的2个不同数据表中的值传递给Crystal报表时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文