'field list' MySQL 异常中的未知列
Unknown column in 'field list' MySQL Exception
如何解决这个问题
MySql.Data.MySqlClient.MySqlException (0x80004005): Unknown column '@ProductTypeId' in 'field list'
↵ at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
↵ at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
↵ at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
↵ at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
↵ at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
↵ at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
↵ at System.Data.Common.DbCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)
↵--- End of stack trace from previous location where exception was thrown ---
↵ at EwingsPlatform.Core.Repositories.Implementations.ProductRepository.InsertAsync(Product entity) in D:_New Product\New folder\master\EwingsPlatform.Core\Repositories\Implementations\ProductRepository.cs:line 292
↵ at EwingsApp.Controllers.ProductController.PostApplicationProduct(CreateProductViewModel applicationProduct) in D:_New Product\New folder\master\EwingsPlatform.AdminWeb\Controllers\ProductController.cs:line 166
↵ at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
↵ at System.Threading.Tasks.ValueTask`1.get_Result()
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
↵ at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
↵ at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
↵ at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
↵ at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
↵ at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)"
StatusCode: 500
该错误基本上是说您尝试使用的内容与数据库中的内容不匹配。
请确保 @ProductTypeId
存在于数据库中。
请检查您的 table 是否已将此 ID 放入 table @ProductTypeId
我发现问题出在插入 SP 中
CREATE DEFINER=
root@
localhostPROCEDURE
product_insert(
IN
ProductTypeIdint(11),
@ 缺失 IN
@ProductTypeIdint(11)
如何解决这个问题
MySql.Data.MySqlClient.MySqlException (0x80004005): Unknown column '@ProductTypeId' in 'field list'
↵ at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
↵ at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
↵ at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
↵ at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
↵ at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
↵ at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
↵ at System.Data.Common.DbCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)
↵--- End of stack trace from previous location where exception was thrown ---
↵ at EwingsPlatform.Core.Repositories.Implementations.ProductRepository.InsertAsync(Product entity) in D:_New Product\New folder\master\EwingsPlatform.Core\Repositories\Implementations\ProductRepository.cs:line 292
↵ at EwingsApp.Controllers.ProductController.PostApplicationProduct(CreateProductViewModel applicationProduct) in D:_New Product\New folder\master\EwingsPlatform.AdminWeb\Controllers\ProductController.cs:line 166
↵ at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
↵ at System.Threading.Tasks.ValueTask`1.get_Result()
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
↵ at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
↵ at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
↵ at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
↵ at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
↵ at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
↵ at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
↵ at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)"
StatusCode: 500
该错误基本上是说您尝试使用的内容与数据库中的内容不匹配。
请确保 @ProductTypeId
存在于数据库中。
请检查您的 table 是否已将此 ID 放入 table @ProductTypeId
我发现问题出在插入 SP 中
CREATE DEFINER=
root@
localhostPROCEDURE
product_insert(
IN
ProductTypeIdint(11),
@ 缺失 IN
@ProductTypeIdint(11)