⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 Copy One Table from mySQL to MS SQL
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, ADODB;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ADOConnection1: TADOConnection;
    ADOConnection2: TADOConnection;
    ADOQuery1: TADOQuery;
    ADOQuery2: TADOQuery;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  i,n: Integer;
begin
  ADOConnection1.ConnectionString := 'DRIVER={MySQL ODBC 3.51 Driver};SERVER=127.0.0.1;DATABASE=TSBQueueDB;UID=Tevin;PWD=Tevin;OPTION=3';
  ADOConnection2.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=sa;Initial Catalog=TSBQueueDB;Data Source=(local)';
  try
    ADOConnection1.Open;
    ADOConnection2.Open;
    ADOQuery1.SQL.Text := 'Select * from Call_History where Get_date>='+QuotedStr('2009/01/01')+' and Get_date<='+QuotedStr('2009/01/31');
    //ADOQuery1.SQL.Text := 'Select * from Call_History where Get_date='+QuotedStr('2009/01/21')+' and recv_no='+QuotedStr('103');
    ADOQuery1.Open;
    n:=0;
    for i:=0 to ADOQuery1.RecordCount-1 do begin
        try
        ADOQuery2.Close;
        ADOQuery2.SQL.Text := 'Insert into Call_History (BranchID, QTlr_No, Get_Date, Get_Time, Call_Time, End_Time, Wait_Time, Proc_Time, Service_Type, Recv_No, Max_Wait) Values (' +
                               QuotedStr( ADOQuery1.FieldByName('BranchID').AsString )     + ',' +
                               QuotedStr( ADOQuery1.FieldByName('QTlr_No').AsString )      + ',' +
                               QuotedStr( ADOQuery1.FieldByName('Get_Date').AsString )     + ',' +
                               QuotedStr( ADOQuery1.FieldByName('Get_Time').AsString )     + ',' +
                               QuotedStr( ADOQuery1.FieldByName('Call_Time').AsString )    + ',' +
                               QuotedStr( ADOQuery1.FieldByName('End_Time').AsString )     + ',' +
                               QuotedStr( ADOQuery1.FieldByName('Wait_Time').AsString )    + ',' +
                               QuotedStr( ADOQuery1.FieldByName('Proc_Time').AsString )    + ',' +
                               QuotedStr( ADOQuery1.FieldByName('Service_Type').AsString ) + ',' +
                               QuotedStr( ADOQuery1.FieldByName('Recv_No').AsString )      + ',' +
                               QuotedStr( ADOQuery1.FieldByName('Max_Wait').AsString )     + ')' ;
        ADOQuery2.ExecSQL;
        ADOQuery2.Close;
        ADOQuery1.Next;
        //
        inc(n);
        Edit1.Text := inttostr(n);
        Application.ProcessMessages;
        Sleep(20);
        except
        end;
    end;
  except
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -