水晶报表 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右键-属性-高级-管理员身份运行 即可
随机推荐
- bind - 将一个名字和一个套接字绑定到一起
SYNOPSIS 概述 #include <sys/types.h> #include <sys/socket.h> int bind(int sockfd, struct s ...
- jquery中ajax使用error调试错误
error:function (XMLHttpRequest, textStatus, errorThrown) { } XMLHttpRequest.readyState状态码 0:未初始化还没有 ...
- splice用法解析
splice()方法算是最强大的数组方法了,它有很多种用法,主要用于删除指定位置的数组项,在指定的位置插入数组项,在指定位置替换数组项,slpice()方法始终都会返回一个数组,该数组包括从原始数组中 ...
- 在vue中场景,循环行,点击当前行编辑数据
当前列表 点击编辑,行变为编辑框. <Row style="color:#999;margin-bottom:11px"> <Row style="ma ...
- Leetcode 54:Spiral Matrix 螺旋矩阵
54:Spiral Matrix 螺旋矩阵 Given a matrix of m x n elements (m rows, n columns), return all elements of t ...
- windows/linux 更新python pip
linux环境下 pip install -U pip windows环境下 python -m pip install -U pip python -m pip install --upgrade ...
- android 获取application和activity下meta-data中的值
meta-data在AndroidManifest中是以键值对的形式存在的,可以将meta-data放在application根节点下,也可以放在某个activity节点下.因为存放的位置不同,因此获 ...
- js正则表达式,只允许输入纯数字或‘/’
//输入框,限数字和/----需要多个数量询价,请以/分隔 function onlyonce(obj) {//先把非数字的都替换掉,除了数字和.obj.value = obj.value.repla ...
- [Python3网络爬虫开发实战] 1.2.3-ChromeDriver的安装
前面我们成功安装好了Selenium库,但是它是一个自动化测试工具,需要浏览器来配合使用,本节中我们就介绍一下Chrome浏览器及ChromeDriver驱动的配置. 首先,下载Chrome浏览器,方 ...
- 零基础入门学习Python(3)--小插曲之变量和字符串
前言 小甲鱼说,在对前边的小游戏改善前,先了解下,Python中的变量与字符串. 主要内容 变量 变量名就像我们现实社会的名字,把一个值赋值给一个名字时,Ta会存储在内存中,称之为变量(variabl ...