D
DreamTiger
Unregistered / Unconfirmed
GUEST, unregistred user!
我想删除一个表的所有纪录,用Diamond Access的Query如下:
procedure TDMod.EmptyTable(sTableName:string);
var
query1:TDaoQuery;
begin
query1 := TDaoQuery.Create(self);
query1.database := SequencesDatabase;
try
query1.SQL.Text := 'DELETE * FROM ' + sTableName + ' WHERE SeqID <> ""';
try
query1.Active := true;
except
end;
finally
query1.free;
end;
end;
总是出错:无效的操作。
当然,不用Delete语句就可以:
try
query1.SQL.Text := 'SELECT * FROM ' + sTableName;
try
query1.Active := true;
while not query1.isempty do query1.delete;
except
end;
finally
query1.free;
end;
这样是可以的,说明query1和database都不是只读的。问题就是delete
为什么用不了?我察看了access中对dao的介绍,可以用delete * From
table where condition 来删除多个纪录的啊。
到底是哪里出的错?
procedure TDMod.EmptyTable(sTableName:string);
var
query1:TDaoQuery;
begin
query1 := TDaoQuery.Create(self);
query1.database := SequencesDatabase;
try
query1.SQL.Text := 'DELETE * FROM ' + sTableName + ' WHERE SeqID <> ""';
try
query1.Active := true;
except
end;
finally
query1.free;
end;
end;
总是出错:无效的操作。
当然,不用Delete语句就可以:
try
query1.SQL.Text := 'SELECT * FROM ' + sTableName;
try
query1.Active := true;
while not query1.isempty do query1.delete;
except
end;
finally
query1.free;
end;
这样是可以的,说明query1和database都不是只读的。问题就是delete
为什么用不了?我察看了access中对dao的介绍,可以用delete * From
table where condition 来删除多个纪录的啊。
到底是哪里出的错?