我有这个引用,它一直向我显示错误:
方法`getDistinctRegister5'没有重载需要1个参数。
private int getDistinctRegister5(string module, string sij)
{
string dateFrom = TbDateFrom.Text.Trim();
string dateTo = TbDateTo.Text.Trim();
string strConnectionString = ConfigurationManager.ConnectionStrings["SilverInfocomm"].ConnectionString;
SqlConnection myConnect = new SqlConnection(strConnectionString);
string sql = "SELECT COUNT( DISTINCT NRIC) FROM REGISTER WHERE Module='" + module + "' AND SIJ='" + sij + "'";
if (dateTo != "" && dateTo != "")
{
sql += "AND Date>= CONVERT(DATETIME,'" + dateFrom + "',103) AND Date <= CONVERT(DATETIME,'" + dateTo + "',103)";
}
else if (dateFrom != "")
{
sql += "AND DATE= CONVERT(DATETIME,'" + dateFrom + "',103)";
}
SqlCommand cmd = new SqlCommand(sql, myConnect);
myConnect.Open();
int numrows = (int)cmd.ExecuteScalar();
myConnect.Close();
return numrows;
}
protected void GetSIJDetails()
{
SIJDetailsDT = new DataTable();
SIJDetailsDT.Columns.Add("SIJ", typeof(string));
SIJDetailsDT.Columns.Add("MODULE", typeof(string));
SIJDetailsDT.Columns.Add("PLACES", typeof(string));
SIJDetailsDT.Columns.Add("UNIQUE", typeof(string));
SIJDetailsDT.Columns.Add("TOTALUNIQUE", typeof(string));
SIJDetailsDT.Columns.Add("NON-UNIQUE", typeof(string));
SIJDetailsDT.Columns.Add("TOTALNONUNIQUE", typeof(string));
DataTable SIJTmp = new DataTable();
string strConnectionString = ConfigurationManager.ConnectionStrings["SilverInfocomm"].ConnectionString;
SqlConnection myConnect = new SqlConnection(strConnectionString);
SqlCommand cmd = new SqlCommand("Select DISTINCT SIJ, Module FROM Register", myConnect);
myConnect.Open();
SqlDataReader reader = cmd.ExecuteReader();
SIJTmp.Load(reader);
reader.Close();
myConnect.Close();
foreach (DataRow dr in SIJTmp.Rows)
{
int PlacesSIJ = getPlacesSIJ(dr["SIJ"].ToString());
int DistinctRegister4 = getDistinctRegister4(dr["SIJ"].ToString());
int TotalRegister4 = getTotalRegister4(dr["SIJ"].ToString());
int DistinctRegister5 = getDistinctRegister5(dr["Module"].ToString());
int TotalRegister2 = getTotalRegister2(dr["Module"].ToString());
SIJDetailsDT.Rows.Add(dr["SIJ"], dr["Module"], PlacesSIJ.ToString(), DistinctRegister5.ToString(), DistinctRegister4.ToString(), TotalRegister2.ToString(), TotalRegister4.ToString());
}
}
弹出错误的行是
int DistinctRegister5 = getDistinctRegister5(dr["Module"].ToString());
答案 0 :(得分:0)
您的getDistinctRegister5
方法有两个参数module
和sij
。
您需要在调用方法时提供这两种方法,
答案 1 :(得分:0)
你在这里只用一个参数调用getDistinctRegister5
函数。
int DistinctRegister5 = getDistinctRegister5(dr["Module"].ToString());
但是在功能定义中有两个参数。所以你应该在调用时传递两个参数。
功能定义
int getDistinctRegister5(string module, string sij)