我是这样做的,但运行后总是说:缺少用户和角色名
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter user :user identified by :psw');
ADOQuery1.ConnectionString:=
'Provider=MSDAORA.1;Password='+OldPswEdit.Text+';User ID='+ComboBox1.Text+';Data Source=oradb;Persist Security Info=True';
ADOQuery1.Parameters[0].DataType:=ftString;
ADOQuery1.Parameters[0].Value:=userEdit.text;
ADOQuery1.Parameters[1].DataType:=ftString;
ADOQuery1.Parameters[1].Value:=NewPswEdit.Text;
try
ADOQuery1.ExecSQL;
except
on EOLEException:Exception do ShowMessage('密码不正确,请重新输入');
end;
ShowMessage('口令修改成功,请记住新口令');
其中的SQL语句:alter user UserName identified by NewPassword
在SQL*PLUS中是好用的。
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter user :user identified by :psw');
ADOQuery1.ConnectionString:=
'Provider=MSDAORA.1;Password='+OldPswEdit.Text+';User ID='+ComboBox1.Text+';Data Source=oradb;Persist Security Info=True';
ADOQuery1.Parameters[0].DataType:=ftString;
ADOQuery1.Parameters[0].Value:=userEdit.text;
ADOQuery1.Parameters[1].DataType:=ftString;
ADOQuery1.Parameters[1].Value:=NewPswEdit.Text;
try
ADOQuery1.ExecSQL;
except
on EOLEException:Exception do ShowMessage('密码不正确,请重新输入');
end;
ShowMessage('口令修改成功,请记住新口令');
其中的SQL语句:alter user UserName identified by NewPassword
在SQL*PLUS中是好用的。
數據庫的用戶操作數據庫,當然改口令是聯接到服務器后使用命令去改了。
改口令不是sql語句,你怎么能這么執行呢?
你换一个有系统管理员权限(如System)登录再试试
ADOQuery1.SQL.Clear;
ADOQuery1.ConnectionString:=
'Provider=MSDAORA.1;Password='+OldPswEdit.Text+';User ID='+ComboBox1.Text+';Data Source=oradb;Persist Security Info=True';
ADOQuery1.SQL.Add('alter user '+userEdit.text+' identified by '+NewPswEdit.Text);
try
ADOQuery1.ExecSQL;
except
on EOLEException:Exception do ShowMessage('密码不正确,请重新输入');
end;
ShowMessage('口令修改成功,请记住新口令');???如果还不行,是不是你的权限不够?
你写程序,不把修改用户口令写在程序里,还要用户自己去数据库修改口令?
再说,如果用户在客户端,他怎么去数据库里修改口令?
按照你那样说的,还是不行,提示:无效的ALTER命令。
我这样做,就一点问题都没有:
ADOQuery1.SQL.Add('alter user UserName identified by NewPassword')
ADOQuery1.ConnectionString:='Provider=MSDAORA.1;Password='+OldPswEdit.Text+';User ID='+ComboBox1.Text+';Data Source=oradb;Persist Security Info=True';
所以我觉得还是SQL语句的传递上有问题,不知道该怎么表示。
ADOQuery1.SQL.Add('alter user "'+UpperCase(ComboBox1.Text)+'" identified by "'+NewPswEdit.Text+'"');