主题:为什么每次只能修改一条记录啊
我已经用了for循环语句了,但每次只能修改一条记录
...
i:=listbox2.Items.Count;
if listbox2.Items.Text='' then showmessage('请先选择符合条件的人')
else
begin
if messagedlg('确认添加这'+inttostr(i)+'条记录吗?',mtconfirmation,[mbyes,mbno],0)=mryes then
begin
xm:=listbox2.Items[i-1];
str1:='update t_info set id="2" where xm="'+xm+'" ';
[color=008080][color=0000FF][color=FF0000]for i:= listbox2.Items.Count downto 1 do
begin
with tquery.Create(nil) do
begin
try
close;
databasename:='dbdemos';
sql.Clear;
sql.Add(str1);
execsql;
finally
free;
end;
end;
next;[/color][/color][/color]
end;
...
i:=listbox2.Items.Count;
if listbox2.Items.Text='' then showmessage('请先选择符合条件的人')
else
begin
if messagedlg('确认添加这'+inttostr(i)+'条记录吗?',mtconfirmation,[mbyes,mbno],0)=mryes then
begin
xm:=listbox2.Items[i-1];
str1:='update t_info set id="2" where xm="'+xm+'" ';
[color=008080][color=0000FF][color=FF0000]for i:= listbox2.Items.Count downto 1 do
begin
with tquery.Create(nil) do
begin
try
close;
databasename:='dbdemos';
sql.Clear;
sql.Add(str1);
execsql;
finally
free;
end;
end;
next;[/color][/color][/color]
end;