查看: 923|回复: 2
|
Crystal Report收不到Data..
[复制链接]
|
|
我的Project是Web Application..
现在,我用SQL Select出我要的Data..然后放进Dataset
Code 是这样。。
Me.SqlSelectCommand1.CommandText = "Select * from testing"
Me.Dataset11.Clear()
Me.SqlDataAdapter1.Fill(Me.Dataset11, "rpt")
然后在Crystal Report里面,我Connect去我的Dataset, 然后拉出我要的Value..
接着我用Coding convert去.PDF的file..
Code是
Private Function PrintDocument(ByVal SourceReport As Object, ByVal FormatType As CrystalDecisions.Shared.ExportFormatType, ByVal PaperSize As CrystalDecisions.Shared.PaperSize, ByVal PaperOrientation As CrystalDecisions.Shared.PaperOrientation)
With SourceReport.FormatEngine.PrintOptions
.PaperSize = PaperSize
.PaperOrientation = PaperOrientation
End With
Dim st As System.IO.Stream
Dim b() As Byte
st = SourceReport.ExportToStream(FormatType)
Page.Response.ClearHeaders()
Page.Response.ContentType = "application/pdf"
ReDim b(st.Length)
st.Read(b, 0, CInt(st.Length))
Page.Response.BinaryWrite(b)
Page.Response.End()
End Function
然后按Print后。。
Private Sub btnprint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprint.Click
Me.SqlSelectCommand1.CommandText = "Select * from testing"
Me.Dataset11.Clear()
Me.SqlDataAdapter1.Fill(Me.Dataset11, "rpt")
Me.TextBox1.Text = Me.Dataset11.Tables("rpt").Rows(0)("ID")
(这行是确定我的Dataset已经有了Value)
Dim myRpt As New ReportDocument
myRpt.Site = Me.Site
Try
myRpt.Load(MapPath("../abc/RPTtesting.Rpt"))
PrintDocument(myRpt, CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat, CrystalDecisions.[Shared].PaperSize.PaperLetter, CrystalDecisions.[Shared].PaperOrientation.Portrait)
Catch ex As Exception
Exit Sub
End Try
PDF出来了,可是空空的,问题出在哪儿呢?
[ 本帖最后由 Mr^MOon 于 28-3-2006 09:40 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 30-3-2006 06:54 PM
|
显示全部楼层
你的 rpt file 是什么来create的, 是crystal report 还是 visual studio? 建议先用 crystal report viewer 来display rpt. 如果还是没有data, 那因该是你rpt file 的design 出了问题。 还有在你的code 里面, dataset 好像完全没有用处? |
|
|
|
|
|
|
|

楼主 |
发表于 30-3-2006 08:08 PM
|
显示全部楼层
是的,Dataset要用到。。
加多一行。。
myRpt.setDataSource(me.Dataset11)
可以了。。谢谢答复
[ 本帖最后由 Mr^MOon 于 30-3-2006 08:09 PM 编辑 ] |
|
|
|
|
|
|
| |
本周最热论坛帖子
|