gpt4 book ai didi

c# - 内存数据库 : Error 1049 - while executing procedure

转载 作者:行者123 更新时间:2023-12-05 04:04:22 27 4
gpt4 key购买 nike

我正在学习 MemSQL,作为其中的一部分,我试图从 C# 客户端代码执行一个过程。存储过程存在于 MemSQL 数据库中。但是,我收到错误“发生错误 1049:未知数据库‘mysql’”。这个问题只出现在一个过程中,如果我从 C# 客户端执行一个简单的查询,它工作正常。

我正在使用 MySql.Data.MySqlClient .Net 核心类库 6.8.8。

最佳答案

尝试将连接选项 CheckParameters 设置为 false。

.NET MySQL 驱动程序尝试查询 mysql 数据库以获取有关存储过程参数的信息,这不适用于 MemSQL。

来自 https://dev.mysql.com/doc/connector-net/en/connector-net-programming-stored.html (存档):

When you call a stored procedure (in versions before the MySQL 8.0 release series), the command object makes an additional SELECT call to determine the parameters of the stored procedure. You must ensure that the user calling the procedure has the SELECT privilege on the mysql.proc table to enable them to verify the parameters. Failure to do this will result in an error when calling the procedure.

这是默认行为,但可以使用连接选项进行更改:

来自 https://dev.mysql.com/doc/connector-net/en/connector-net-6-10-connection-options.html (存档):

CheckParameters , Check Parameters

Default: true

Indicates if stored routine parameters should be checked against theserver.

这个选项适用于旧版本的客户端:

UseProcedureBodies , Use Procedure Bodies , procedure bodies

Default: true

When set to true, the default value, Connector/NET expects the body ofthe procedure to be viewable. This enables it to determine theparameter types and order. Set the option to false when the userconnecting to the database does not have the SELECT privileges for themysql.proc (stored procedures) table or cannot viewINFORMATION_SCHEMA.ROUTINES, and then explicitly set the types of allthe parameters before the call and add the parameters to the commandin the same order as they appear in the procedure definition.

This option was deprecated in Connector/NET 6.3.7 and removed inConnector/NET 6.10.4; use the Check Parameters option instead.

关于c# - 内存数据库 : Error 1049 - while executing procedure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52598354/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com