找回密码
 立即注册

QQ登录

只需一步,快速开始

ptc_admin

注册会员

3

主题

4

帖子

93

积分

注册会员

积分
93
最新发帖
ptc_admin
注册会员   /  发表于:2018-4-12 18:02  /   查看:3465  /  回复:1
使用数据库:sqlserver2012
问题描述:页面单值参数可以获取到数据,多值参数获取不到数据,应该是传递不到存储过程中,(其中存储过程是将页面传过来的多值字符串用逗号分隔),确认下多值参数传递到存储过程的格式
报错提示:

错误明细:
GrapeCity.ActiveReports.ReportException: 无法连接数据源 ---> System.Data.SqlClient.SqlException: 过程或函数 'Report_cust_GetCustomerInfo' 需要参数 '@CustomerRegisterSource',但未提供该参数。
   在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   在 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   在 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   在 System.Data.SqlClient.SqlDataReader.get_MetaData()
   在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)
   在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   在 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   在 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   在 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   在 GrapeCity.BI.Data.DataProviders.SysCommandAdapter.ExecuteReader()
   在 #UwA.#uue.ExecuteReader(IDbConnection connection, IDbTransaction transaction)
   在 GrapeCity.BI.Data.RecordScanner.RecordSet.<GetEnumerator>d__5.MoveNext()
   --- 内部异常堆栈跟踪的结尾 ---
   在 GrapeCity.Enterprise.Data.DataEngine.Extensions.EnumerableExtensions.MemoizedBuffer`1.#7kY(Boolean& hasValue)
   在 GrapeCity.Enterprise.Data.DataEngine.Extensions.EnumerableExtensions.MemoizedBuffer`1.<GetEnumerator_>d__9.MoveNext()
   在 GrapeCity.Enterprise.Data.DataEngine.DataProcessing.TablixImpl.<>c__DisplayClass2_0`1.#zo2(T member)
   在 GrapeCity.Enterprise.Data.DataEngine.DataProcessing.DataProcessor.TxMember.get_Ordinal()
   在 GrapeCity.Enterprise.Data.DataEngine.DataProcessing.DataProcessor.TxMember.#QjX(ExecutionContext ctx)
   在 GrapeCity.Enterprise.Data.DataEngine.DataProcessing.DataProcessor.<>c__DisplayClass19_1.#vm2(TxMember m)
   在 System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   在 System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   在 System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   在 GrapeCity.Enterprise.Data.DataEngine.DataProcessing.DataProcessor.<>c__DisplayClass19_0.#pm2(ExecutionContext exc)
   在 GrapeCity.Enterprise.Data.DataEngine.DataProcessing.DataProcessor.<>c__DisplayClass18_1.#mm2(#TRZ fn)
   在 System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   在 System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   在 System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   在 GrapeCity.Enterprise.Data.DataEngine.DataProcessing.DataProcessor.<>c__DisplayClass18_1.#lm2()
   在 GrapeCity.Enterprise.Data.DataEngine.DataTree`1.Scope.get_Regions()
   在 GrapeCity.Enterprise.Data.DataEngine.DataProcessing.DataTreeGenerator.<>c__DisplayClass17_1.#fn2()
   在 GrapeCity.Enterprise.Data.DataEngine.DataTree`1.Scope.get_Regions()
   在 GrapeCity.Enterprise.Data.DataEngine.DataTree`1.Scope.get_IsEmpty()
   在 GrapeCity.ActiveReports.Rendering.Data.DataScopeBase.#BHA(Content content, Scope scope, Int32 index)
   在 GrapeCity.ActiveReports.Rendering.Data.DataScopeBase.#BHA(String name)
   在 #wxA.#UzA.Create(ReportRenderingContext reportRenderingContext, ReportItem rdlItem, IDataScopeInternal currentDataContext)
   在 GrapeCity.ActiveReports.Rendering.ReportRenderingContext.<>c__DisplayClass13.#sf2(ReportItem item)
   在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   在 System.Linq.Enumerable.<ConcatIterator>d__58`1.MoveNext()
   在 System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   在 System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
   在 System.Linq.Enumerable.<SelectIterator>d__5`2.MoveNext()
   在 System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   在 System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   在 GrapeCity.ActiveReports.Layout.L2.CanvasImpl.#n3V[T](IEnumerable`1 canvasItems)
   在 GrapeCity.ActiveReports.Layout.L2.#AY(IEnumerable`1 canvasItems, Boolean galleyMode, Object item, Int32 width, Int32 height, Boolean consumeWhiteSpace)
   在 GrapeCity.ActiveReports.Layout.L2.#AY(IEnumerable`1 canvasItems, Boolean galleyMode, Object item, Int32 width, Int32 height, Boolean canShrink, Boolean canGrow, Boolean consumeWhiteSpace)
   在 GrapeCity.ActiveReports.Layout.ReportCanvasLayout.#AY(IEnumerable`1 items, #saR context, Object item, Int32 width, Int32 height, Boolean canShrink, Boolean canGrow, Boolean consumeWhiteSpace)
   在 GrapeCity.ActiveReports.Layout.ReportImpl.#QaX(#saR context, IBody body, Object item, Size`1 contentSize, Nullable`1 size, Boolean consumeWhiteSpace)
   在 GrapeCity.ActiveReports.Layout.LayoutEngine.#Lv0(#saR context, Int32 limit)
   在 GrapeCity.ActiveReports.Layout.LayoutEngine.BuildLayout(LayoutInfo layoutInfo)
   在 #GPr.#RLf.#NNf(IReport report, TargetDeviceCapabilities targetDevice, LayoutNotificationCallback callback)
   在 GrapeCity.ActiveReports.Export.Image.Page.ImageRenderingExtension.Render(IReport report, StreamProvider streams, NameValueCollection settings)
   在 GrapeCity.ActiveReports.Document.PageDocument.Render(IRenderingExtension renderingExtension, StreamProvider streams, NameValueCollection settings, Boolean forceDataRefresh, Boolean forceParameterDataRefresh)
   在 GrapeCity.ActiveReports.Viewer.Win.Rdlx.RdlReport.<>c__DisplayClassf.#7yz()
   在 GrapeCity.ActiveReports.Viewer.Win.AsyncLoader.<>c__DisplayClass7.#cAz(Object param0, DoWorkEventArgs param1)
   在 System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   在 System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)



1 个回复

倒序浏览
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2018-4-12 18:25:59
沙发
您好!
ODBC数据源不支持多值参数,可以使用动态拼接SQL语句的方法绕过此问题。

核心是:
(1)脚本
Function ArrayToString(list As Object()) As String
    Dim re =""
    For Each item AsString In list
        If item IsNothing Then
            ContinueFor
        End If
        
        If re<> "" Then
            re +=","
        End If
        
        re += item
    Next
    Return re
End Function
(2)数据集SQL使用表达式
="select * from city where CountryCode in ("& Code.ArrayToString( Parameters!CountryCode.Value ) & ")"

="select  *from Test2  WHERE 业务编号 In ('" +Join(Split(Code.ArrayToString( Parameters!P1.Value ), ","), "','") + "')"

操作办法:首先写一个脚本把输入的多值(数组的形式),合并成一个string类型的,然后在用Split函数进行一个分割。


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部