CSDN博客

img sunyujia

原创Oracle数据库导入导出工具

发表于2008/9/29 16:17:00  7102人阅读

分类: 其他

因为自己记忆力比较差,经常记不住命令,注意不是一般的差,是太差了,另外也比较懒惰,所以想写个小东西,释放下劳动力.于是有了个想法,写个导入导出数据库的小工具,免得每次敲命令麻烦,尤其是文件路径,在cmd下面修改很费劲.

十一在家没事做,时机来了,起初想用脚本语言来写,比如批处理调用vbs,vbs利用ie做GUI,后来发现单调vbs脚本可以,但是用批处理调vbs,ie就起不来了,而且效果也不是很好,干脆写个小程序算了(java就免了不够麻烦的),庆幸我还懂点delphi 就会点皮毛,不过由于delphi比较简单,虽然我大学接触了三年的c++(基本和没学一样),但是我仍然觉得比不上我根本没学过的delphi简单.这就是差距了,自己太菜了,只能使用些比较容易上手的语言了.vb还是算了,机器上没有开发环境.前几天正好下了个精简版的delphi,这年头,连开发工具都玩起了精简绿化,不得不寒啊...

估计来看我博客的都是搞java的,对源码不感兴趣,但是我还是准备贴出来,以防不时之需,利用ShellExecute可以启动java噢,有兴趣的可以看看.没兴趣看源码的,就试用下这个小工具吧,Delphi牛人来了就当路过好了...

这是我的第一个完整的delphi程序,处女作啊,具有纪念价值.

下载地址(我的csdn资源):http://download.csdn.net/source/657522

 

  1. unit Unit2;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls,shellapi, CustomizeDlg;
  6. type
  7.   TForm1 = class(TForm)
  8.     execButton: TButton;
  9.     userNameEdit: TEdit;
  10.     userNameLabel: TLabel;
  11.     impRadio: TRadioButton;
  12.     expRadio: TRadioButton;
  13.     databaseEdit: TEdit;
  14.     databaseLabel: TLabel;
  15.     fromUserLabel: TLabel;
  16.     passwordLabel: TLabel;
  17.     passwordEdit: TEdit;
  18.     fromUserEdit: TEdit;
  19.     toUserLabel: TLabel;
  20.     toUserEdit: TEdit;
  21.     OpenDialog1: TOpenDialog;
  22.     extCmdLineEdit: TEdit;
  23.     Button3: TButton;
  24.     FileLabel: TLabel;
  25.     extCmdLabel: TLabel;
  26.     fileEdit: TEdit;
  27.     cmdLineEdit: TEdit;
  28.     blogLabel: TLabel;
  29.     procedure execButtonClick(Sender: TObject);
  30.     procedure Button3Click(Sender: TObject);
  31.     procedure blogLabelMouseEnter(Sender: TObject);
  32.     procedure blogLabelMouseLeave(Sender: TObject);
  33.     procedure blogLabelClick(Sender: TObject);
  34.     procedure databaseEditChange(Sender: TObject);
  35.     procedure chgCmdLine();
  36.     procedure FormCreate(Sender: TObject);
  37.     procedure impRadioClick(Sender: TObject);
  38.     procedure expRadioClick(Sender: TObject);
  39.     procedure userNameEditChange(Sender: TObject);
  40.     procedure passwordEditChange(Sender: TObject);
  41.     procedure fromUserEditChange(Sender: TObject);
  42.     procedure toUserEditChange(Sender: TObject);
  43.     procedure extCmdLineEditChange(Sender: TObject);
  44.     procedure fileEditChange(Sender: TObject);
  45.     procedure FormDestroy(Sender: TObject);
  46.   private
  47.     { Private declarations }
  48.   public
  49.     { Public declarations }
  50.   end;
  51. var
  52.   Form1: TForm1;
  53.   batFile:textfile; 
  54. implementation
  55. {$R *.dfm}
  56. procedure TForm1.execButtonClick(Sender: TObject);
  57. begin
  58.       assignfile(batFile,'temp.bat');
  59.       rewrite(batFile);
  60.       writeln(batFile,'%~1'+#10+'pause');
  61.       closefile(batFile);
  62.       ShellExecute(Application.Handle, 'open''temp.bat'pchar('"'+cmdLineEdit.text+'"'), nil, SW_SHOW);
  63. end;
  64. procedure TForm1.Button3Click(Sender: TObject);
  65. begin
  66. OpenDialog1.Filter:= '备份文件|*.dmp|所有文件|*.*';
  67. if OpenDialog1.Execute then
  68. begin
  69. fileEdit.text:=OpenDialog1.FileName;
  70. end;
  71. end;
  72. procedure TForm1.blogLabelMouseEnter(Sender: TObject);
  73. begin
  74.   blogLabel.Font.style:=[fsUnderline];
  75. end;
  76. procedure TForm1.blogLabelMouseLeave(Sender: TObject);
  77. begin
  78.   blogLabel.Font.Style:=[];
  79. end;
  80. procedure TForm1.blogLabelClick(Sender: TObject);
  81. begin
  82. ShellExecute(Handle, 'Open''http://blog.csdn.net/sunyujia/''''', SW_SHOWNORMAL);
  83. end;
  84. procedure TForm1.databaseEditChange(Sender: TObject);
  85. begin
  86.   chgCmdLine();
  87.   extCmdLineEdit.Text:='log='+databaseEdit.Text+'.log';
  88.   fileEdit.Text:=databaseEdit.Text+'.dmp';
  89. end;
  90. procedure TForm1.chgCmdLine();
  91. begin
  92.  cmdLineEdit.text:=userNameEdit.text+'/'+passwordEdit.text+'@'+databaseEdit.text;
  93.  if impRadio.Checked=true then
  94.  begin
  95.     cmdLineEdit.text:='imp '+cmdLineEdit.text+' fromuser='+fromuserEdit.text+' '+'touser='+touserEdit.text+' ';
  96.  end else
  97.  begin
  98.     cmdLineEdit.text:='exp '+cmdLineEdit.text+' owner='+fromuserEdit.text+' ';
  99.  end;
  100.   cmdLineEdit.text:=cmdLineEdit.text+' file="'+fileEdit.text+'" '+extCmdLineEdit.text;
  101. end;
  102. procedure TForm1.userNameEditChange(Sender: TObject);
  103. begin
  104. chgCmdLine();
  105. fromuserEdit.text:=usernameEdit.text;
  106. touserEdit.text:=usernameEdit.text;
  107. end;
  108. procedure TForm1.FormDestroy(Sender: TObject);
  109. begin
  110. DeleteFile('temp.bat');
  111. end;
  112. procedure TForm1.FormCreate(Sender: TObject);
  113. begin
  114. chgCmdLine();
  115. end;
  116. procedure TForm1.impRadioClick(Sender: TObject);
  117. begin
  118. chgCmdLine();
  119. end;
  120. procedure TForm1.expRadioClick(Sender: TObject);
  121. begin
  122. chgCmdLine();
  123. end;
  124. procedure TForm1.passwordEditChange(Sender: TObject);
  125. begin
  126. chgCmdLine();
  127. end;
  128. procedure TForm1.fromUserEditChange(Sender: TObject);
  129. begin
  130. chgCmdLine();
  131. end;
  132. procedure TForm1.toUserEditChange(Sender: TObject);
  133. begin
  134. chgCmdLine();
  135. end;
  136. procedure TForm1.extCmdLineEditChange(Sender: TObject);
  137. begin
  138. chgCmdLine();
  139. end;
  140. procedure TForm1.fileEditChange(Sender: TObject);
  141. begin
  142. chgCmdLine();
  143. end;
  144. end.

 

0 0

相关博文

我的热门文章

img
取 消
img