c# – MySql.Data.MySqlClient.MySqlException(0x80004005):SELECT命令被拒绝用户’XXX’@’YYY’用于表’bogus_table’

c# – MySql.Data.MySqlClient.MySqlException(0x80004005):SELECT命令被拒绝用户’XXX’@’YYY’用于表’bogus_table’,第1张

概述我正在使用Dapper来调用 MySql存储过程.该过程执行得很好,但在此之后代码抛出异常.有问题的代码块是这样的: using (var conn = DataFactory.InitializeConnection(false)) { conn.Query("ProcedureName", new { puserid = ID 我正在使用Dapper来调用 MySql存储过程.该过程执行得很好,但在此之后代码抛出异常.有问题的代码块是这样的:

using (var conn = DataFactory.InitializeConnection(false))    {        conn.query("Procedurename",new        {            puserID = ID        },commandType: System.Data.CommandType.StoredProcedure);    }

DataFactory是以下静态类:

public static class DataFactory{    public static IDbConnection InitializeConnection(bool open = true,string connectionstring = "",string databaseServerType = "MysqL")    {        if (string.Equals(databaseServerType,"MysqL"))        {            if (string.IsNullOrEmpty(connectionstring))                connectionstring = Settings.Default.DataConnectionString;            var csb = new mysql.data.MysqLClIEnt.MysqLConnectionStringBuilder(connectionstring);            var conn = new mysql.data.MysqLClIEnt.MysqLConnection(csb.ConnectionString);            Dapper.DefaultTypeMap.MatchnamesWithUnderscores = true;            if (open)                conn.open();            return conn;        }        throw new NotImplementedException("Not implemented for your database provIDer");    }}

我的数据库中没有bogus_table,它显示在错误消息中:

mysql.data.MysqLClIEnt.MysqLException (0x80004005): SELECT command
denIEd to user ‘XXX’@’YYY’ for table ‘bogus_table’ 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.MysqLDataReader.ClearKillFlag()
at mysql.data.MysqLClIEnt.MysqLDataReader.Close() at
mysql.data.MysqLClIEnt.MysqLDataReader.dispose(Boolean disposing)
at mysql.data.MysqLClIEnt.MysqLDataReader.dispose() at
Dapper.sqlMapper.d__1361.<>m__Finally1() at
Dapper.sqlMapper.<queryImpl>d__136
1.MoveNext()

解决方法 这可能是 Mysql Driver实施中的问题;这里是提到 bogus_table的代码块.
如果你的过程有空结果,尝试用Execute调用(因为它实现了内部执行非查询)而不是query.

using (var conn = DataFactory.InitializeConnection(false))    {        conn.Execute("Procedurename",commandType: System.Data.CommandType.StoredProcedure);    }
总结

以上是内存溢出为你收集整理的c# – MySql.Data.MySqlClient.MySqlException(0x80004005):SELECT命令被拒绝用户’XXX’@’YYY’用于表’bogus_table’全部内容,希望文章能够帮你解决c# – MySql.Data.MySqlClient.MySqlException(0x80004005):SELECT命令被拒绝用户’XXX’@’YYY’用于表’bogus_table’所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1233147.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存