with datamodule6.ADOQuery3 do
begin
if active then
close;
SQL.Clear;
SQL.add('select * from 用户');
ExecSQL;
open;
if RecordCount>0 then
begin
first;
if Locate('帐号,用户级别',vararrayof([strUser,未审核']),[locaseinsensitive]) then
begin
if application.messagebox(确定通过?', '提示',mb_YesNo+MB_APPLMODAL+MB_ICONQUESTION+MB_DEFBUTTON2)=idyes then
begin
edit;
fieldByName('用户级别').AsString:='user';
post;
end
else
exit;
end;
end;
DataModule6.ADOQuery3.Refresh;
end;
此条记录数据库里面已经存在,我只是修改,但出错,什么原因?
错误提示:由于在主关键字,索引值,主键中存在重复的记录,不能保存!!
begin
if active then
close;
SQL.Clear;
SQL.add('select * from 用户');
ExecSQL;
open;
if RecordCount>0 then
begin
first;
if Locate('帐号,用户级别',vararrayof([strUser,未审核']),[locaseinsensitive]) then
begin
if application.messagebox(确定通过?', '提示',mb_YesNo+MB_APPLMODAL+MB_ICONQUESTION+MB_DEFBUTTON2)=idyes then
begin
edit;
fieldByName('用户级别').AsString:='user';
post;
end
else
exit;
end;
end;
DataModule6.ADOQuery3.Refresh;
end;
此条记录数据库里面已经存在,我只是修改,但出错,什么原因?
错误提示:由于在主关键字,索引值,主键中存在重复的记录,不能保存!!
解决方案 »
- DELPHI7中一个很高难的问题
- 使用ShellExecute需要引用哪个单元,我的会报错!!
- 大家评一下
- 我想在A1、A2、B1、B2中随机抽出一个,该怎么做,用哪个函数?
- 医学影像系统解决方案
- Delphi中能否将函数或者过程作为参数传递,如果可以的话麻烦给了例子先!
- 让我做个pos系统,但是一点不会,请问那里有这方面的网站!
- 我想自己绘制滚动条,请大家给点建议!
- wwtable4: dataset not in edit or insert mode ???我就弄不懂为什么TABLE也会提示这个错???
- 对于TreeView如何实现节点连选呢,比如说按下SHIFT,点击节点一次选中多个,象WINDOWS那样的,
- 549告别帖
- 简单的问题
SQL.add('select * from 用户');
ExecSQL;
open;
>>>>
ExecSQL;是没有用的open 就可以了
////////////////////////////////////////
open;
///////////////////////////////////
edit;
fieldByName('用户级别').AsString:='user';
post;
end
begin
first;???????????????? next 呢?
if Locate('帐号,用户级别',vararrayof([strUser,未审核']),[locaseinsensitive]) then
begin
if application.messagebox(确定通过?', '提示',mb_YesNo+MB_APPLMODAL+MB_ICONQUESTION+MB_DEFBUTTON2)=idyes then
begin
edit;
fieldByName('用户级别').AsString:='user';
begin
if RecordCount>0 then
begin
first;
if Locate('帐号;用户级别',vararrayof([strUser,'未审核']),[locaseinsensitive]) then
begin
while not eof do
begin
if fieldByName('帐号').AsString=strUser then
begin
if application.messagebox('确定拒绝此用户?', '提示',mb_YesNo+MB_APPLMODAL+MB_ICONQUESTION+MB_DEFBUTTON2)=idyes then
delete
else
exit;
end;
next;
end;
end;
end;
CleaNilEdit;
DataModule6.ADOQuery3.Refresh;
end;
我这样好像就可以了
这么写不对,fieldByName().AsString只能给变量附值,如果修改数据库字段的值,要用
SQL语句的Update语句,例如:
update 表名 set 字段名= where 限制条件= ;
to: saien(有问必答)
这一句不出错,我要看到修改后的记录,所以肯定是要要的!是执行post;时候出错!
with datamodule6.ADOQuery3 do
begin
if RecordCount>0 then
begin
first;
if Locate('帐号,用户级别',vararrayof([strUser,'未审核']),[locaseinsensitive]) then
begin
while not eof do
begin
if fieldByName('帐号').AsString=strUser then
begin
if application.messagebox('确定通过?, '提示',mb_YesNo+MB_APPLMODAL+MB_ICONQUESTION+MB_DEFBUTTON2)=idyes then
begin
edit;
fieldByName('用户级别').AsString:='user';
post;
end
else
exit;
end;
next;
end;
end;
end;
CleaNilEdit;
DataModule6.ADOQuery3.Refresh;
end;
这样不好,大家帮我改改,谢谢!