我已经验证我的方法/Oracle 过程工作正常,但在我的 C# 中,我总是从 ExecuteNonQuery() 返回 -1。因此,下面的布尔值总是错误的。我们只在我们的数据库 (Oracle) 中将触发器用于 INSERT 语句。我需要更新语句的触发器吗?
有什么建议为什么会发生?它肯定更新了一条记录:
public bool ChangePassword(long UserId, string NewPassword)
{
int rcds = 0;
using (OracleConnection dbConn = new OracleConnection(dbConnString))
using (OracleCommand dbCmd = new OracleCommand("PKG_USER.CHANGE_PASSWORD", dbConn))
{
try
{
string salt = GenerateSalt();
dbCmd.CommandType = CommandType.StoredProcedure;
dbCmd.Parameters.Add("p_USER_ID", OracleDbType.Int64, UserId, ParameterDirection.Input);
dbCmd.Parameters.Add("P_PASSWORD", OracleDbType.Varchar2, 128, EncodePassword(NewPassword, this.IsPasswordHashed, salt), ParameterDirection.Input);
dbCmd.Parameters.Add("P_PASSWORD_SALT", OracleDbType.Varchar2, 128, salt, ParameterDirection.Input);
if (dbConn.State != ConnectionState.Open) dbConn.Open();
rcds = dbCmd.ExecuteNonQuery();
}
catch (Exception e)
{
LastError = e.Message + " " + e.Source;
rcds = 0;
}
finally
{
dbCmd.Dispose();
dbConn.Dispose();
}
}
return (rcds > 0);
}
对不起...继承人SP:
PROCEDURE Change_Password(p_User_Id IN Users.User_Id%TYPE,
p_Password IN Users.Password%TYPE,
p_Password_Salt IN Users.Password_Salt%TYPE) IS
BEGIN
UPDATE Users
SET Password = p_Password,
Password_Salt = p_Password_Salt,
Password_Change_Date = SYSDATE
WHERE User_Id = p_User_Id;
END Change_Password;