moer 发表于 2024-7-17 13:57:10

【9.0】"从数据类型 nvarchar 转换为 bigint 时出错




同一个视图,查询条件,如上。同样的查询代码,输入查询条件1971 ,查询OK
输入查询条件1970就出错





/Forguncy/Home/GetTableDataWithOffset
Internal Server Error
Request Exception Happened-------------------------------
Path/Home/GetTableDataWithOffset
UserName:administrator
{
"ClassName": "System.Data.SqlClient.SqlException",
"Message": "从数据类型 nvarchar 转换为 bigint 时出错。",
"Data": {
    "$type": "System.Collections.ListDictionaryInternal, System.Private.CoreLib",
    "HelpLink.ProdName": "Microsoft SQL Server",
    "HelpLink.ProdVer": "14.00.1000",
    "HelpLink.EvtSrc": "MSSQLServer",
    "HelpLink.EvtID": "8114",
    "HelpLink.BaseHelpUrl": "https://go.microsoft.com/fwlink",
    "HelpLink.LinkId": "20476",
    "SqlError 1": "System.Data.SqlClient.SqlError: 从数据类型 nvarchar 转换为 bigint 时出错。"
},
"InnerException": null,
"HelpURL": null,
"StackTraceString": "   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows)
   at System.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more)
   at System.Data.SqlClient.SqlDataReader.<>c__DisplayClass190_0.<ReadAsync>b__1(Task t)
   at System.Data.SqlClient.SqlDataReader.InvokeRetryable(Func`2 moreFunc, TaskCompletionSource`1 source, IDisposable objectToDispose)
--- End of stack trace from previous location ---
   at Forguncy.DataSourceBase.FillTableAsync(String commandText, IEnumerable`1 parameters)
   at ForguncyDataAccess.DataAccess.a(String A_0, String A_1, DataBaseType A_2, DbParameter[] A_3)
   at ForguncyDataAccess.DataAccess.SelectAsync(List`1 columnBindingInfos, ISqlCondition selectCondition, TopSqlConditionBase topCondition, String tableName, OrderBySqlCondition orderByCondition, OffsetSqlCondition offsetCondition, Boolean useGroupBy)
   at Forguncy.Server2.ForguncyServerDataAccess.SelectAsync(List`1 columnBindingInfos, ISqlCondition selectCondition, TopSqlConditionBase topCondition, String tableName, OrderBySqlCondition orderByCondition, OffsetSqlCondition offsetCondition, Boolean useGroupBy)
   at ForguncyDataAccess.DataAccess.GetDetailDataTableAsync(List`1 columnBindingInfos, ISqlCondition sqlCondition, TopSqlConditionBase topCondition, OrderBySqlCondition orderByCondition, List`1 primaryKeys, OffsetSqlCondition offsetCondition, Boolean distinct, Boolean ensureOrderBy)
   at ForguncyDataAccess.DataAccess.GetDataTableAsync(List`1 columnBindingInfos, ISqlCondition sqlCondition, TopSqlConditionBase topCondition, List`1 primaryKeys, OrderBySqlCondition orderByCondition, OffsetSqlCondition offsetCondition, Boolean distinct, Boolean ensureOrderBy)
   at Forguncy.Server2.ForguncyServerDataAccess.GetDataTableAsync(List`1 columnBindingInfos, ISqlCondition sqlCondition, TopSqlConditionBase topCondition, List`1 primaryKeys, OrderBySqlCondition orderByCondition, OffsetSqlCondition offsetCondition, Boolean distinct, Boolean ensureOrderBy)
   at Forguncy.Server2.Controllers.HomeController.a(List`1 A_0, Int32 A_1, OffsetSqlCondition A_2, Boolean A_3, ISqlCondition A_4, TopSqlConditionBase A_5, OrderBySqlCondition A_6, List`1 A_7, IDataAccess A_8)
   at Forguncy.Server2.Controllers.HomeController.a(List`1 A_0, CurrentRowInfo A_1, Int32 A_2, Int32 A_3, Boolean A_4, QueryCommandInfo A_5, List`1 A_6, String A_7, OffsetSqlCondition A_8, Boolean A_9, ColumnFilterQuery[] A_10, Boolean A_11, List`1 A_12, Boolean A_13, Boolean A_14)
   at Forguncy.Server2.Controllers.HomeController.a(List`1 A_0, CurrentRowInfo A_1, Int32 A_2, Int32 A_3, Boolean A_4, QueryCommandInfo A_5, List`1 A_6, String A_7, OffsetSqlCondition A_8, Boolean A_9, ColumnFilterQuery[] A_10, Boolean A_11, List`1 A_12, Boolean A_13, Boolean A_14)
   at Forguncy.Server2.Controllers.HomeController.n.a.d()
--- End of stack trace from previous location ---
   at Forguncy.Server2.Controllers.HomeController.a(CacheSetting A_0, String A_1, Object A_2, Func`1 A_3)
   at Forguncy.Server2.Controllers.HomeController.GetTableDataWithOffset(GetTableDataWithOffsetParam data)
   at lambda_method1440(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Forguncy.Server2.KatanaMiddleware.CodeEditorMiddleware.InvokeAsync(HttpContext context)
   at Forguncy.Server2.KatanaMiddleware.ProcessEngineMiddleware.InvokeAsync(HttpContext context, ICacheService cacheService)
   at Forguncy.Server2.KatanaMiddleware.ReportsMiddleware.InvokeAsync(HttpContext context, ICacheService cacheService, IReportServerService reportServerService)
   at Forguncy.KatanaMiddleware.ServerCommandMiddleware.InvokeAsync(HttpContext context)
   at Forguncy.KatanaMiddleware.k.InvokeAsync(HttpContext context)
   at Forguncy.KatanaMiddleware.j.InvokeAsync(HttpContext context)
   at Forguncy.Server2.KatanaMiddleware.StartPageMiddleware.InvokeAsync(HttpContext context)
   at ForguncyServerCommon.HttpHeaderMiddlewareBase.InvokeAsync(HttpContext context)
   at Forguncy.KatanaMiddleware.q.InvokeAsync(HttpContext context)",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": -2146232060,
"Source": "Core .Net SqlClient Data Provider",
"WatsonBuckets": null,
"Errors": null,
"ClientConnectionId": "78867d37-77e5-466c-8713-a6a645a69841"
}


Simon.Sun 发表于 2024-7-17 14:22:57

您好,可以去网络请求里抓一下 SQL,然后去数据库里去执行看看有没有问题。
从错误来看,是数据库底层在做类型转换时报错了。


活字格8.0 update1新功能解密:十七、浏览器日志提升-查看数据请求执行SQL
https://gcdn.grapecity.com.cn/showtopic-152845-1-1.html
(出处: 葡萄城开发者社区)

moer 发表于 2024-7-17 14:38:35

没有SqLItems

moer 发表于 2024-7-17 15:03:19

我查下编号(数字),查询的字段也是字符串。 然后活字格帮它当成数字去查询字符串字段了?

Simon.Sun 发表于 2024-7-17 17:24:26

本帖最后由 Lay.Li 于 2024-7-24 11:22 编辑

大佬,假设是 SQL 问题的话,这个看日志报错不太好定位原因。
您那边可以用不报错的参数去查询下,把 SQL 拿到,然后用报错的参数作为过滤条件再数据库查询下,看会报错不。
页: [1]
查看完整版本: 【9.0】"从数据类型 nvarchar 转换为 bigint 时出错