posts - 72, comments - 19, trackbacks - 0, articles - 0

导入导SQL;

Posted on 2006-08-01 15:45 阅读(72) 评论(0)  编辑 收藏 引用 所属分类: oracle学习

//Access
//Access->TXT
procedure TForm1.Button1Click(Sender: TObject); begin
  sSql := 'select * into [Text;Database=f:\].aaa.txt from demo';
  with AccessConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//Access->DBF
procedure TForm1.Button3Click(Sender: TObject); begin
  sSql := 'select * into aaa in ''f:\'' ''dbase 5.0;'' from demo';
  with AccessConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//Access->Excel
//注意:前一个aaa为Excel文件中的aaa页,后一个aaa为Access文件demo.mdb中的一个
表名
procedure TForm1.Button9Click(Sender: TObject); begin
  sSql :=
    'select * into aaa from aaa in ''E:\Delphilx\ADOSQL\PH\demo.mdb''';
  with ExcelConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//Access->Access
procedure TForm1.Button4Click(Sender: TObject); begin
  sSql := 'select * into aaa from demo in ''E:\Delphilx\ADOSQL\PH\demo.mdb''';
  with AccessConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//TXT->Access
procedure TForm1.Button2Click(Sender: TObject); begin
  sSql := 'select * into uform from [Text;Database=f:\].form.txt';
  with AccessConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//DBF->Access
procedure TForm1.Button5Click(Sender: TObject); begin
  sSql := 'select * into aaa from aaa in ''f:\'' ''dbase 5.0;''';
  with AccessConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//Excel->Access
//[aaa$]->Excel文件aaa.xls中的aaa页
procedure TForm1.Button10Click(Sender: TObject); begin
  sSql :=
    'select * into bbb from [excel 8.0;database=f:\aaa.xls].[aaa$]';
  with AccessConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//=================================================================
//Oracle
//Oracle->Access
procedure TForm1.Button6Click(Sender: TObject); begin
  sSql :=
    'select * into ouform from ouform in [ODBC][ODBC;Driver={Microsoft ODBC for Oracle};UID=bklskf;PWD=bklskf;SERVER=bkls;]';
  with AccessConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//Oracle->TXT
procedure TForm1.Button7Click(Sender: TObject); begin
  sSql := 'select VGH,VXM,VMM into lsygb.txt from (select * from lsygb in [ODBC][ODBC;Driver={Microsoft ODBC for Oracle};UID=BKLS;PWD=BKLS;SERVER=BKLS;])';
//  sSql :=
//    'select * into form.txt from ouform in [ODBC][ODBC;Driver={Microsoft
ODBC for Oracle};UID=bklskf;PWD=bklskf;SERVER=bkls;]';
  with TxtConnection do
    begin
      Close;
      Connected := True;
      Execute(sSql);
    end;
end;

//Oracle->Excel
procedure TForm1.Button8Click(Sender: TObject); begin
  sSql :=
    'select * into aaa from lsygb in [ODBC][ODBC;Driver={Microsoft ODBC for Oracle};UID=bkls;PWD=bkls;SERVER=bkls;]';
  with ExcelConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//Oracle->DBF
procedure TForm1.Button11Click(Sender: TObject); begin
  sSql :=
    'select * into aaa from lsygb in [ODBC][ODBC;Driver={Microsoft ODBC for Oracle};UID=bkls;PWD=bkls;SERVER=bkls;]';
  with DBFConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//TXT->Oracle
//Oracle数据库注意要将表名大写!不然创建出来的表可以看到表名但无法打开
procedure TForm1.Button12Click(Sender: TObject); begin
  sSql := 'select * into PH_TXT in [ODBC][ODBC;Driver={Microsoft ODBC for Oracle};UID=bkls;PWD=bkls;SERVER=bkls;] from ph_txt.txt';
  with TxtConnection do
    begin
      Close;
      Connected := True;
      Execute(sSql);
    end;
end;

//DBF->Oracle
procedure TForm1.Button13Click(Sender: TObject); begin
  sSql :=
    'select * into PH_DBF in [ODBC][ODBC;Driver={Microsoft ODBC for Oracle};UID=bkls;PWD=bkls;SERVER=bkls;] from aaa';
  with DBFConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//Access->Oracle
procedure TForm1.Button14Click(Sender: TObject); begin
  sSql :=
    'select * into PH_ACCESS in [ODBC][ODBC;Driver={Microsoft ODBC for Oracle};UID=bkls;PWD=bkls;SERVER=bkls;] from aaa';
  with AccessConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

//Excel->Oracle
procedure TForm1.Button15Click(Sender: TObject); begin //  'select * into MLB in [ODBC][ODBC;Driver={Microsoft ODBC for Oracle};UID=BKLS;PWD=BKLS;Server=BKLS;] from MLB'
//Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\aaa.xls;Extended Properties=Excel 8.0;Persist Security Info=False
  sSql :=
    'select * into PH_EXCEL in [ODBC][ODBC;Driver={Microsoft ODBC for Oracle};UID=bkls;PWD=bkls;SERVER=bkls;] from aaa';
  with ExcelConnection do
    begin
      Connected := True;
      Execute(sSql);
    end;
end;

procedure TForm1.Button16Click(Sender: TObject); begin
  sSql := 'select * into qxb in ''f:\'' ''dbase 5.0;'' from lsqxb.txt';
  with TXTConnection do
    begin
//      Close;
//      ConnectionString :=
'Provider=Microsoft.Jet.OLEDB.4.0;Password="";Data Source=f:\temp;Extended Properties="text;HDR=YES;FMT=Delimited";Persist Security Info=True';
      Connected := True;
      Execute(sSql);
    end;
end;


2004-1-14 21:17:00   
只有注册用户登录后才能发表评论。