小弟的代码是:procedure TForm1.Button2Click(Sender: TObject);
var str:string;
begin
str:='确实要删除用户'+ Trim(query1.fieldbyname ('recmac').AsString)+ '?';
if Application.messagebox(pchar(str),'删除',MB_YESNO)=ID_YES then
begin
while not (Query1.Eof) do
begin
query1.Delete;
end
end;
当查找出来的是多条记录时为什么老是报错,希望那为老大能够解决,谢谢了!!!!希望贴出代码出来!!!小弟刚开始编程
var str:string;
begin
str:='确实要删除用户'+ Trim(query1.fieldbyname ('recmac').AsString)+ '?';
if Application.messagebox(pchar(str),'删除',MB_YESNO)=ID_YES then
begin
while not (Query1.Eof) do
begin
query1.Delete;
end
end;
当查找出来的是多条记录时为什么老是报错,希望那为老大能够解决,谢谢了!!!!希望贴出代码出来!!!小弟刚开始编程
var
str:string;
begin
if query1.active then
begin
str:='确实要删除用户'+ Trim(query1.fieldbyname ('recmac').AsString)+ '?';
if Application.messagebox(pchar(str),'删除',MB_YESNO)=ID_YES then
begin
query1.first;
while not (Query1.Eof) do
begin
query1.Delete;
query1.next;
end
end;
end;
end;
//试试;
var str:string;
begin
str:='确实要删除用户'+ Trim(query1.fieldbyname ('recmac').AsString)+ '?';
if Application.messagebox(pchar(str),'删除',MB_YESNO)=ID_YES then
begin
try
query1.DeleteRecords(arll);
except
end;
end;
var
str:string;
begin
if query1.active then
begin
str:='确实要删除用户'+ Trim(query1.fieldbyname ('recmac').AsString)+ '?';
if Application.messagebox(pchar(str),'删除',MB_YESNO)=ID_YES then
query1.DeleteRecords(arllchapters);//换这句看看....
end;
end;
var
str,a:string;
begin
if query1.active then
begin
a:=query1.fieldbyname ('recmac').AsString);
str:='确实要删除用户'+ Trim(a)+ '?';
if Application.messagebox(pchar(str),'删除',MB_YESNO)=ID_YES then
begin
query1.close;
query1.sql.clear;
query1.sql.add('delete from 表 where recmac=''a''');
query1.ExecSQL;
end;
end;
end;