mysql.data.mysqlclient.mysqlexception(0x80004005):对于表“bogus挈u table”,选择拒绝给用户“”@“yyy”的命令

utugiqy6  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(953)

我使用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):在mysql.data.mysqlclient.mysqlstream.readpacket()的mysql.data.mysqlclient.nativedriver.getresult(int32&affectedrow,int64&insertedid)的mysql.data.mysqlclient.driver.nextresult(int32 statementid,boolean force),位于mysql.data.mysqlclient.mysqldatareader.nextresult(),位于mysql.data.mysqlclient.mysqlcommand.executereader(commandbehavior behavior),位于mysql.data.mysqlclient.mysqldatareader.clearkillflag(),位于mysql.data.mysqlclient.mysqldatareader.close(),位于mysql.data.mysqlclient.mysqldatareader.dispose(boolean disposing)
位于mysql.data.mysqlclient.mysqldatareader.dispose(),位于dapper.sqlmapper.d\u136 1.<>m__Finally1() at Dapper.SqlMapper.<QueryImpl>d__136 1.移动下一个()

xvw2m8pv

xvw2m8pv1#

这可能是mysql驱动程序实现中的问题;这是一个提到伪表的代码块。如果过程的结果为空,请尝试使用execute调用(因为它在内部实现了execute non query),而不是query。

using (var conn = DataFactory.InitializeConnection(false))
    {
        conn.Execute("ProcedureName", new
        {
            puserid = ID
        }, commandType: System.Data.CommandType.StoredProcedure);
    }

相关问题