为什么我会收到"无过载的方法有两个参数:QUOT ;? [英] Why am I getting "no overload for method takes two arguments"?
本文介绍了为什么我会收到"无过载的方法有两个参数:QUOT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个DLL的方法:
公共静态数据集ExecuteDataset(字符串strcommandText,的CommandType命令类型,SqlParameter的[] P)
{
创建连接();
DA =新SqlDataAdapter的(strcommandText,CON);
da.SelectCommand.CommandType =命令类型;
da.SelectCommand.Parameters.AddRange(P);
DS =新的DataSet();
da.Fill(DS);
返回DS;
}
和我已经写在另一个DLL的方法:
公共静态数据集GetDeptDetails()
{
字符串strcommandText =sp_DeptDetails;
返回SqlHelper.ExecuteDataset(strcommandText,CommandType.StoredProcedure);
}
在这里,我得到这个错误:
无过载的方法有两个参数。
块引用>我在做什么错了?
解决方案公共静态数据集ExecuteDataset(字符串strcommandText,的CommandType命令类型,SqlParameter的[] P = NULL)
{
创建连接();
DA =新SqlDataAdapter的(strcommandText,CON);
da.SelectCommand.CommandType =命令类型;
如果(P!= NULL)
{
da.SelectCommand.Parameters.AddRange(P);
}
DS =新的DataSet();
da.Fill(DS);
返回DS;
}
公共静态数据集GetDeptDetails()
{
字符串strcommandText =sp_DeptDetails;
返回SqlHelper.ExecuteDataset(strcommandText,CommandType.StoredProcedure);
}I have a method in one DLL:
public static DataSet ExecuteDataset(string strcommandText,CommandType commandType,SqlParameter[] p) { CreateConnection(); da = new SqlDataAdapter(strcommandText, con); da.SelectCommand.CommandType = commandType; da.SelectCommand.Parameters.AddRange(p); ds = new DataSet(); da.Fill(ds); return ds; }
And I have written a method in another DLL:
public static DataSet GetDeptDetails() { string strcommandText = "sp_DeptDetails"; return SqlHelper.ExecuteDataset(strcommandText,CommandType.StoredProcedure); }
Here, I'm getting this error:
no overload for method takes two arguments.
What am I doing wrong?
解决方案public static DataSet ExecuteDataset(string strcommandText,CommandType commandType,SqlParameter[] p=null) { CreateConnection(); da = new SqlDataAdapter(strcommandText, con); da.SelectCommand.CommandType = commandType; if(p!=null) { da.SelectCommand.Parameters.AddRange(p); } ds = new DataSet(); da.Fill(ds); return ds; } public static DataSet GetDeptDetails() { string strcommandText = "sp_DeptDetails"; return SqlHelper.ExecuteDataset(strcommandText,CommandType.StoredProcedure); }
这篇关于为什么我会收到"无过载的方法有两个参数:QUOT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文