VB.Net 2005 水晶报表连接ACCESS数据库路径问题?请高手帮忙...

hehaiyi2008 2011-03-08 09:45:47
【工程组成及代码】
一个工程中,已经有一个设计好的水晶报表rep_BookTypes.rpt;
另外在一个窗体上使用CrystalReportViewer1控件调用设计好的rep_BookTypes.rpt报表;
窗体引用CrystalReportViewer1控件加载报表的代码如下:

Dim myreport = New rep_BookTypes
Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load

CrystalReportViewer1.ReportSource = myreport '加载报表

End Sub



【我的问题】
数据库使用的是ACCESS数据库,当时数据库地址是在设置向导中设置的绝对地址。现在数据库位置发生变化后,运行报表就会弹出数据库设置的对话框。
我需要解决的问题是:
①如何用代码设置数据库的相对地址?
②如何用代码传递SQL语句?(这样我就可以灵活的设置需要报表显示的数据内容)



代码是我从网上找的,都是比较初级的代码,因为初学.Net 有很多不清楚,还请大家帮忙解决!谢谢!~~~
...全文
214 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ckp00001 2011-03-12
  • 打赏
  • 举报
回复
给一些代码望有帮助:

      Friend WithEvents crvBasic As CrystalDecisions.Windows.Forms.CrystalReportViewer

'======================================================
' Create a report document instance to hold the report
Dim rptExpensiveProducts As New ReportDocument()

  ' Load the report
rptExpensiveProducts.Load("..\TenMostExpensiveProducts.rpt")

  ' Set the report source for the crystal reports
' viewer to the report instance.
crvBasic.ReportSource = rptExpensiveProducts

  ' Zoom viewer to fit to the whole page so the user can see the report
crvBasic.Zoom(2)
沐NeMo 2011-03-10
  • 打赏
  • 举报
回复
其实xxDataTable你要怎么筛选就怎么筛选。
然后设置: myreport.SetDataSource(xxDataTable)
然后再设置你的:CrystalReportViewer1.ReportSource = myreport
就可以了。
---------
设置路径问题,你就设置后,你就不要改变咯。不然就重新设置也不麻烦啊。
本人做过连接SQLServer的类型水晶报表,Access的还没有做过。
或者其他人可以帮到你。
hehaiyi2008 2011-03-09
  • 打赏
  • 举报
回复
怎么没人回答问题啊????
hehaiyi2008 2011-03-09
  • 打赏
  • 举报
回复
大家都不会吗?

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧