用ALTER USER语句替换Oracle参数

时间:2019-05-10 15:41:25

标签: c# oracle oracle-manageddataaccess

尝试用ALTER USER语句替换参数时出现错误。

var cmdTxt = "ALTER USER :USER_NAME IDENTIFIED BY :NEW_PASS";

var cmd = new OracleCommand(cmdTxt, conn);
cmd.CommandType = CommandType.Text;
cmd.BindByName = true;

cmd.Parameters.Add("USER_NAME", OracleDbType.Varchar2, userName, ParameterDirection.Input);
cmd.Parameters.Add("NEW_PASS", OracleDbType.Varchar2, newPW, ParameterDirection.Input);

var ds = new DataSet();
var da = new OracleDataAdapter(cmd);

conn.Open();
da.Fill(ds); // << error ORA-01935: missing user or role name

但是它在SELECT语句中工作正常。

var sql = "SELECT LOG_ID FROM ERR_LOG WHERE LOG_ID = :LOG_ID";

var cmd = new OracleCommand(sql, con);
cmd.CommandType = CommandType.Text;
cmd.BindByName = true;

cmd.Parameters.Add("LOG_ID", OracleDbType.Varchar2, Convert.ToInt64(number), ParameterDirection.Input);
var ds = new DataSet();
var da = new OracleDataAdapter(cmd);

con.Open();
da.Fill(ds); // no error

0 个答案:

没有答案