1

当我尝试从 C# 执行过程时,出现此错误:

Unable to retrieve stored procedure metadata for routine 'test'. Either grant SELECT privilege to mysql.proc for this user or use "check parameters=false" with your connection string.

这是连接字符串:

<add name="MySqlCS" connectionString="Data Source=192.168.x.x;Initial Catalog=z;Persist Security Info=True;User ID=y;Password=y providerName="MySql.Data.MySqlClient"/>

然后我尝试添加这个"check parameters=false"

我明白了:

Access denied for user 'y'@'pcname.domain.local' (using password: YES)

新配置是:

<add name="MySqlCS" connectionString="Data Source=192.168.x.x;Initial Catalog=z;Persist Security Info=True;User ID=y;Password=y CheckParameters=false" providerName="MySql.Data.MySqlClient"/>

我可以使用相同的凭据从 MySQL Workbench 连接,完全没有问题。

这是C#代码:

public static DataSet GetTest(string cname)
        {
            try
            {
                OpenConnection();


                DataTable[] tables = new DataTable[2];


                IDbCommand cmd = myConnection.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "test";

                IDataParameter parCode = cmd.CreateParameter();
                parCode.ParameterName = "Client";
                parCode.DbType = DbType.String;
                parCode.Value = cname;
                parCode.Direction = ParameterDirection.Input;

                cmd.Parameters.Add(parCode);

                //cmd.ExecuteReader();

                IDataReader dr = cmd.ExecuteReader();
                DataSet dset = new DataSet();
                dset.Load(dr, LoadOption.PreserveChanges, tables);

                return dset;

            }
            finally
            {
                CloseConnection();
            }
        }
4

3 回答 3

1

你确定你有所有必需的 dll 库

于 2013-06-04T20:52:13.813 回答
1

在存储过程中尝试 SQL SECURITY INVOKER:

CREATE DEFINER=`prueba`@`%` PROCEDURE `selectEsquemaVacio`()
    SQL SECURITY INVOKER
BEGIN
    SELECT cve_esquema FROM esquema e ORDER BY cve_esquema;

    SELECT cve_ent,cve_mun,cve_loc,esquema,tipo,nom_loc
            FROM localidades l
            where esquema is null or esquema=''
            ORDER BY cve_ent,cve_mun,cve_loc;
END
于 2013-07-03T14:45:01.973 回答
-1

UseProcedureBodies = False;CheckParameters = false

这是工作。

于 2015-07-08T04:22:36.773 回答