运行程序水晶报表提示“加载报表失败”提示
做了报表,报表是直接链接在数据库上用sql写的,没有用那种dataset的那种方法。
程序做好部署发布后,一运行程序,看任何报表模块就出现“加载报表失败”的提示。
水晶报表的发布让我非常不解了~
我先开始认为是水晶报表的key不对,改了还是这样~。
然后又认为是报表路径不对,又继续改~
再然后我只能说我的程序不对~~~~~~~
然后我又认为发布的时候要连着*.rpt文件一起发布,加入了,但是还是不对
没办法了,请各位大虾指点~~~~~~~~~~~~~~~~~~
代码如下
--------------------------------------------------
'这些是查询参数
Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscreteValue
paramField.ParameterFieldName = "sybmmc "
'discreteVal.Value = "{ " & CType(ComboBox1.SelectedValue, Guid).ToString & "} "
discreteVal.Value = ComboBox1.Text
paramField.CurrentValues.Add(discreteVal)
paramFields.Add(paramField)
' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
Dim qds As New ReportDocument
Dim lli As New TableLogOnInfo
Dim ttb As Table
'原来使用绝对路径,怀疑是这里的问题,还是不对
'qds.Load( "D:\VoitureFees\testUI\CrystalReport2.rpt ")
'又把路径改成这样
Dim bbpath, bbpath2 As String
bbpath = Application.StartupPath
bbpath2 = bbpath.Substring(0, bbpath.LastIndexOf( "\ "))
' MessageBox.Show( bbpath2)
qds.Load(bbpath2 & "CrystalReport2.rpt ")
'读文件得到报表的链接数据库字符
Dim SHdbinfo As New ArrayList
Dim myStreamReader As StreamReader
myStreamReader = File.OpenText(Application.StartupPath & "/ " & "quercon.txt ")
Dim str As String
Do
str = myStreamReader.ReadLine
SHdbinfo.Add(str)
Loop Until IsNothing(str)
myStreamReader.Close()
For Each ttb In qds.Database.Tables
lli = ttb.LogOnInfo
With lli.ConnectionInfo
.ServerName = RTrim(SHdbinfo.Item(0))
.DatabaseName = RTrim(SHdbinfo.Item(1))
.UserID = RTrim(SHdbinfo.Item(2))
.Password = RTrim(SHdbinfo.Item(3))
End With
ttb.ApplyLogOnInfo(lli)
Next ttb
CrystalReportViewer1.ReportSource = qds
' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
CrystalReportViewer1.ParameterFieldInfo = paramFields
CrystalReportViewer1.ReportSource = qds
CrystalReportViewer1.Show()
[解决办法]
UP
[解决办法]
代中不要把直接路在面
你的RPT可一放在目的某用目中
[解决办法]
没必要那么复杂吧,打包的时候有几个模块需要合并,而且建议你直接用dataset 比较好操作!
具体详细情况联系 654645788
[解决办法]
不要用绝对路径读取啊,用相对了
[解决办法]
up