水晶报表 Crystal Report 调用存储过程时出错 找不到表 ,解决方法。
用 CrystalReportViewer1 控件在asp.net的网页上显示报表,假设做报表时调用数据表数据的方式调用是能够成功的。但报表是用存储过程获取数据方式会出现下面错误:
找不到表'RptOpenCheck;1' 。 文件 G:\TEMP\FO-OpenCheck {6D191F06-DECF-4A25-88FC-8553E3D435AA}.rpt 内出错: 找不到表。
Error: 未将对象引用设置到对象的实例。
The table 'RptOpenCheck;1' could not be found. Error in File G:\TEMP\FO-OpenCheck {6D191F06-DECF-4A25-88FC-8553E3D435AA}.rpt: The table could not be found.
未能打开该连接。 未能打开该连接。
G:\TEMP\FO-OpenCheck {4E60249E-FC16-4F3D-A610-138FC3297171}.rpt
VS2005 环境,Crsytal Reports 11.5
代码下面:
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim crParameterFields As ParameterFields
Dim crParameterField As ParameterField
Dim crParameterValues As ParameterValues
Dim crParameterDefValues As ParameterValues
Dim crParameterValue As ParameterValue
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim CrTables As Tables
Dim CrTable As Table
Dim ReportName As String
Dim PrintTo As String ' P Printer V Window
Dim ReportPath As String
Dim UserName As String
Dim Password As String
Dim ServerName As String
Dim DatabaseName As String
Dim crReportDocument As New ReportDocument
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
Dim strParam As String = Request("p")
'获取用户请求參数
If Right(strParam, 1) = "~" Then
strParam = Mid(strParam, 1, Len(strParam) - 1)
End If
'參数转换为数组
s = Split(strParam, "~")
'use odbc connection database
With crConnectionInfo
.AllowCustomConnection = True
.ServerName = ”ODBCName"
'.DatabaseName = "TempDB"
.UserID = "sa"
.Password = "Microwin"
End With
''use SQL connection database
'With crConnectionInfo
' .AllowCustomConnection = True
' .ServerName = "(local)"
' .DatabaseName = "TempDB"
' .UserID = "sa"
' .Password = "Microwin"
'End With
'指定报表路径
ReportPath = Server.MapPath(Request.ApplicationPath)
ReportNamePath = ReportPath & "\testing.rpt"
'check report file exists and Load Report
If System.IO.File.Exists(ReportNamePath) Then
crReportDocument.Load(ReportNamePath)
End If
'设置报表文档给报表控件
Me.CrystalReportViewer1.ReportSource = crReportDocument
'设置连接数据库信息给报表文档
CrTables = crReportDocument.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
'就是这句没有加,所以会出现以上错误信息。仅仅有报表是调用存储过程取数据时才会出现错误。花了我几天时间,最终攻克了。
CrTable.Location = CrTable.Name
Next
'设置控件显示的属性
With CrystalReportViewer1
.AutoDataBind = True
.ReuseParameterValuesOnRefresh = True
.EnableDatabaseLogonPrompt = False
.EnableParameterPrompt = False
CrystalReportViewer1.DisplayGroupTree = False
CrystalReportViewer1.DisplayPage = True
CrystalReportViewer1.DisplayToolbar = True
CrystalReportViewer1.ReportSource = crReportDocument
End With
If Not IsPostBack Then
'取用户请求的參数赋值给报表。假设报表须要參数的话。从第三个元素開始为报表參数值。
crParameterFields = Nothing
crParameterFields = CrystalReportViewer1.ParameterFieldInfo
Dim j As Integer = UBound(s, 1)
For i = 0 To crParameterFields.Count - 1
crParameterField = crParameterFields.Item(i)
crParameterValues = crParameterField.CurrentValues
crParameterDefValues = Nothing
crParameterDefValues = New ParameterValues
crParameterDefValues = crParameterField.DefaultValues
crParameterDiscreteValue = Nothing
crParameterDiscreteValue = New ParameterDiscreteValue
If i > (j - 2) Then
Select Case crParameterField.ParameterValueKind
Case ParameterValueKind.BooleanParameter
crParameterDiscreteValue.Value = False
Case ParameterValueKind.CurrencyParameter
crParameterDiscreteValue.Value = Nothing
Case ParameterValueKind.DateParameter
crParameterDiscreteValue.Value = System.DateTime.Now
Case ParameterValueKind.DateTimeParameter
crParameterDiscreteValue.Value = System.DateTime.Now
Case ParameterValueKind.NumberParameter
crParameterDiscreteValue.Value = Nothing
Case ParameterValueKind.StringParameter
crParameterDiscreteValue.Value = " "
Case ParameterValueKind.TimeParameter
crParameterDiscreteValue.Value = System.DateTime.Now
End Select
crParameterValues.Add(crParameterDiscreteValue)
Else
Select Case crParameterField.ParameterValueKind
Case ParameterValueKind.BooleanParameter
crParameterDiscreteValue.Value = IIf(s(i + 2) = "0", False, True)
Case ParameterValueKind.CurrencyParameter
crParameterDiscreteValue.Value = IIf(Trim(s(i + 2) & "") = "", Nothing, s(i + 2))
Case ParameterValueKind.DateParameter
crParameterDiscreteValue.Value = IIf(Trim(s(i + 2) & "") = "", Nothing, s(i + 2))
Case ParameterValueKind.DateTimeParameter
crParameterDiscreteValue.Value = IIf(Trim(s(i + 2) & "") = "", Nothing, s(i + 2))
Case ParameterValueKind.NumberParameter
crParameterDiscreteValue.Value = IIf(Trim(s(i + 2) & "") = "", Nothing, s(i + 2))
Case ParameterValueKind.StringParameter
crParameterDiscreteValue.Value = IIf(Trim(s(i + 2) & "") = "", " ", s(i + 2))
Case ParameterValueKind.TimeParameter
crParameterDiscreteValue.Value = IIf(Trim(s(i + 2) & "") = "", Nothing, s(i + 2))
End Select
crParameterValues.Add(crParameterDiscreteValue)
End If
Next
End If
End Sub
水晶报表 Crystal Report 调用存储过程时出错 找不到表 ,解决方法。的更多相关文章
- Visual Studio 2012使用水晶报表Crystal Report
原文:Visual Studio 2012使用水晶报表Crystal Report SAP在 2013年1月14日 released SAP Crystal Reports,developer ver ...
- 如何将水晶报表(Crystal Report)导入葡萄城报表
当从旧的报表平台迁移到葡萄城报表工具时,意味着有大量的报表设计工作要重复去做,如果有一款工具能够在这些工具之间进行自由转换,就能省去报表开发几乎一半的工作量. 葡萄城报表为兼容其他报表控件,提供了简单 ...
- 用C#调用C++DLL提示找不到DLL解决方法【转】
用C#调用自己写的C++ DLL(x64),总是提示找不到DLL,调试可以,发布release老是提示找不到DLL(dll文件确定存在) 原因:Visual C++的DLL分发方式没选:调试默认选择: ...
- 部署包含水晶报表Crystal Reports 的VS.NET2005应用程序[原创]
要部署包含水晶报表Crystal Reports 的应用程序,您需要在生成解决方案之前创建一个安装项目,并且向应用程序中添加必要的合并模块. 1.打开 VS.NET2005 编程IDE. 2.在解决方 ...
- SQL SERVER使用ODBC 驱动建立的链接服务器调用存储过程时参数不能为NULL值
我们知道SQL SERVER建立链接服务器(Linked Server)可以选择的驱动程序非常多,最近发现使用ODBC 的 Microsoft OLE DB 驱动程序建立的链接服务器(Linked S ...
- EF 6 调用存储过程时返回多结果集和OUTPUT参数问题
原文地址:http://q.cnblogs.com/q/56836/ 各位大侠,提问一个关于EF6调用存储过程时返回多结果集和OUTPUT参数问题 目前已经可以调用存储过程并且可以返回多个结果集. 但 ...
- 报表学习总结(一)——ASP.NET 水晶报表(Crystal Reports)的简单使用
一.水晶报表简介 Crystal Reports(水晶报表)是一款商务智能(BI)软件,主要用于设计及产生报表.水晶报表是业内最专业.功能最强的报表系统,它除了强大的报表功能外.最大的优势是实现了与绝 ...
- (转)创建DB2实例时出错,请大家帮忙解决
创建DB2实例时出错,请大家帮忙解决 原文:http://bbs.chinaunix.net/thread-3601748-1-1.html 运行:$DB2DIR/instance/db2icrt ...
- 架设传奇时打开DBC数据库出错或读取DBC失败解决方法
架设传奇时打开DBC数据库出错或读取DBC失败解决方法 DBC右键-属性-高级-管理员身份运行 即可
随机推荐
- numpy add
在numpy中,'+' 和add 是一样的 np.add(x1, x2) x1+x2 有种特殊情况需要注意,x1和x2的shape不一样的加法: 两个shape不一样的array相加后会变成一个com ...
- js进行的一些判断
表达式 "^\\d+$" //非负整数(正整数 + 0) "^[0-9]*[1-9][0-9]*$" //正整数 "^((-\\d+)|(0+))$& ...
- Oracle排名函数(Rank)实例详解
这篇文章主要介绍了Oracle排名函数(Rank)实例详解,需要的朋友可以参考下 --已知:两种排名方式(分区和不分区):使用和不使用partition --两种计算方式(连续,不连续),对应 ...
- 题解 洛谷P2147/BZOJ2049【[SDOI2008]洞穴勘测】
Link-Cut-Tree的模板题啊......(听说还可以用其他的方法做,不管了,直接上LCT) 没有要求维护点权,只需要维护点的连通性即可. 就是朴素的LCT,居然还不要pushup. 感觉有些不 ...
- java1.8学习-什么样的匿名内部类能被lambda语法代替?
java1.8学习-什么样的匿名内部类能被lambda语法代替? java1.8好多新的特性真的很有意思,特别是Lambda.在学习的时候发现并不是所有的匿名内部类都可以用Lambda代替. lamb ...
- Buffer.from(arrayBuffer[, byteOffset[, length]])
Buffer.from(arrayBuffer[, byteOffset[, length]]) arrayBuffer - 一个 TypedArray 或 new ArrayBuffer() 的 . ...
- 【BZOJ 1202】 [HNOI2005]狡猾的商人(枚举区间也可行)
题链:http://www.lydsy.com/JudgeOnline/problem.php?id=1202 其实也可以不使用加权并查集,通过画图可以发现,一个长区间和其包含的区间能够算出一个新区间 ...
- UVa 210 并行程序模拟(deque)
题意: 模拟n个程序运行 格式一共有5种:var = constant(赋值):print var(打印):lock:unlock:end, 上述5种语句分别需要t1.t2.t3.t4.t5单位时间 ...
- HDU4463-Outlets,简单最小生成树。1A水过~~
Outlets ...
- Spark 动态(统一)内存管理模型
作者编辑:王玮,胡玉林 一.回顾 在前面的一篇文章中我们介绍了spark静态内存管理模式以及相关知识https://blog.csdn.net/anitinaj/article/details/809 ...