数据集无法找到表0

时间:2015-02-10 14:14:24

标签: c# asp.net dataset

我有以下方法

private DataSet passwordManagement(int reseller_ID, string username, string password, int processType, DateTime? PasswordResetDate, bool? IsPasswordReset, string newPassword)
        {
            DataSet passwordManagement = new DataSet();


            SqlParameter[] PasswordManagementStoredProceduredParamaters = new SqlParameter[8];
            PasswordManagementStoredProceduredParamaters = SqlHelperParameterCache.GetSpParameterSet(uf.SecretPass(strConn), "PasswordManagement");

            dbconn.Open();

            PasswordManagementStoredProceduredParamaters[0].Value = reseller_ID; 
            PasswordManagementStoredProceduredParamaters[1].Value = username; 
            PasswordManagementStoredProceduredParamaters[2].Value = password; 
            PasswordManagementStoredProceduredParamaters[3].Value = processType; 
            PasswordManagementStoredProceduredParamaters[4].Value = PasswordResetDate; 
            PasswordManagementStoredProceduredParamaters[5].Value = DateTime.Today.AddYears(3); 
            PasswordManagementStoredProceduredParamaters[6].Value = IsPasswordReset; 
            PasswordManagementStoredProceduredParamaters[7].Value = newPassword; 


            passwordManagement = SqlHelper.ExecuteDataset(dbconn, CommandType.StoredProcedure, "PasswordManagement", PasswordManagementStoredProceduredParamaters);
            passwordManagement.Tables[0].TableName = "passwordManagement";

            dbconn.Close();

            return passwordManagement;
        }

我尝试返回数据集但是我得到了以下异常

找不到表0

添加到代码端的内容是什么?

1 个答案:

答案 0 :(得分:0)

在您尝试访问dataset -

之前进行检查
if(passwordManagement.Tables.Count > 0)
     passwordManagement.Tables[0].TableName = "passwordManagement";

还要检查您的procedure是否返回了传递参数的行。