label2.caption:='c:\cbj\cbj.dbf';
copyfile(pchar(ExtractFilePath(label2.caption)+'mtemp.dbf')
,pchar(ExtractFilePath(label2.caption)+'down.dbf')
,false);
if pos('.',ExtractFileName(label2.caption))<>0 then
tname:=copy(ExtractFileName(label2.caption),1,pos('.',ExtractFileName(label2.caption))-1)
else
tname:=ExtractFileName(label2.caption);
try
adoconnection1.ConnectionString :=
'Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=dandong;UID=;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;SourceDB='+ExtractFilePath(label2.caption)+';"';
adotable1.TableName:=tname;
adonew.TableName:='down';
adoquery1.SQL.clear;
ADOquery1.SQL.Add ('alter table');
adoquery1.SQL.Add(tname);
adoquery1.SQL.Add('alter dj n(16,2) alter cl n(16,2) alter dj n(7,5) alter zhye n(16,2)');
adoquery1.ExecSQL;
adoconnection1.Connected:=true;
adotable1.Active :=true;
adonew.Active :=true;
except
messagebox(form1.Handle,'数据文件错','错误',0);
adoconnection1.Connected:=false;
exit;
copyfile(pchar(ExtractFilePath(label2.caption)+'mtemp.dbf')
,pchar(ExtractFilePath(label2.caption)+'down.dbf')
,false);
if pos('.',ExtractFileName(label2.caption))<>0 then
tname:=copy(ExtractFileName(label2.caption),1,pos('.',ExtractFileName(label2.caption))-1)
else
tname:=ExtractFileName(label2.caption);
try
adoconnection1.ConnectionString :=
'Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=dandong;UID=;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;SourceDB='+ExtractFilePath(label2.caption)+';"';
adotable1.TableName:=tname;
adonew.TableName:='down';
adoquery1.SQL.clear;
ADOquery1.SQL.Add ('alter table');
adoquery1.SQL.Add(tname);
adoquery1.SQL.Add('alter dj n(16,2) alter cl n(16,2) alter dj n(7,5) alter zhye n(16,2)');
adoquery1.ExecSQL;
adoconnection1.Connected:=true;
adotable1.Active :=true;
adonew.Active :=true;
except
messagebox(form1.Handle,'数据文件错','错误',0);
adoconnection1.Connected:=false;
exit;
alter table tname
alter dj n(16,2) alter cl n(16,2) alter dj n(7,5) alter zhye n(16,2)3.執行表字段的修正「adoquery1.ExecSQL;」
alter table tname
alter dj n(16,2) alter cl n(16,2) alter dj n(7,5) alter zhye n(16,2)3.执行sql语句 adoquery1.ExecSQL