gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 00:30:19 25 4
gpt4 key购买 nike

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

最佳答案

你确定你有所有的required dll's libraries吗?到位。

关于c# - 无法检索例程的存储过程元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16927152/

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