无法检索例程的存储过程元数据

时间:2013-06-04 20:45:09

标签: c# mysql

当我尝试从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();
            }
        }

3 个答案:

答案 0 :(得分:1)

您确定已准备好所有required dll's libraries

答案 1 :(得分: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

答案 2 :(得分:-1)

带有UseProcedureBodies = False;

CheckParameters = false

它正在发挥作用。