str:string;
TableExist:boolean;
TableList:TStringList;
Tableindex:integer;
begin
if opendialog1.Execute then
try
str:=opendialog1.FileName;
ADOQuery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+str+';Persist Security Info=False'; TableExist := false;
TableList := TStringList.Create();
ADquery1. .GetTableNames(TableList,false);
for Tableindex:=0 to TableList.Count-1 do
begin
if TableList[TableIndex]='QueryTable' then
TableExist := true;
end;
if TableExist then //如果表存在,就把它删除
begin
ADOQuery.Close;
ADOQuery.SQL.Clear;
ADOQuery.SQL.Add('Drop Table QueryTable;');
ADOQuery.ExecSQL;
end;
TableExist:boolean;
TableList:TStringList;
Tableindex:integer;
begin
if opendialog1.Execute then
try
str:=opendialog1.FileName;
ADOQuery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+str+';Persist Security Info=False'; TableExist := false;
TableList := TStringList.Create();
ADquery1. .GetTableNames(TableList,false);
for Tableindex:=0 to TableList.Count-1 do
begin
if TableList[TableIndex]='QueryTable' then
TableExist := true;
end;
if TableExist then //如果表存在,就把它删除
begin
ADOQuery.Close;
ADOQuery.SQL.Clear;
ADOQuery.SQL.Add('Drop Table QueryTable;');
ADOQuery.ExecSQL;
end;
assigned(ADquery1.Connection) 必等于nil,
即然等于nil,也就是对象不存在,又何来调用其对象的方法呢。。