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;

解决方案 »

  1.   

    1.「adoconnection1.ConnectionString」表示是用ADO方式連接的数据庫2.在「adoquery1」中装入的是修正表字段的↓SQL文
      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;」
      

  2.   

    1.adoconnection1.ConnectionString ADO方式连接的数据库2.在adoquery1中装入的是修正表字段的SQL
      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