L
lisongmagic
Unregistered / Unconfirmed
GUEST, unregistred user!
如题。代码如下,运行了一下,虽然程序没有报错,但
数据没有从源数据库导进目标数据库,目标数据库仍然为空。
procedure TForm1.Button1Click(Sender: TObject);
procedure oCustomTask2_Trans_S1(oCustomTask2: DataPumpTask2);
var
oTransformationOld: Transformation;
oTransformation: Transformation2;
begin
oTransformationOld := oCustomTask2.Transformations.New('DTS.DataPumpTransformCopy');
oTransformation := oTransformationOld as Transformation2;
oTransformation.Name := 'DirectCopyXform';
oTransformation.TransformFlags := 63;
oTransformation.ForceSourceBlobsBuffered := 0;
oTransformation.ForceBlobsInMemory := False;
oTransformation.InMemoryBlobSize := 1048576;
oTransformation.TransformPhases := 4;
oCustomTask2.Transformations.Add(oTransformation);
oTransformation := nil;
oTransformationOld := nil;
end;
var opackageold: package;
opackage: package2;
dts_conn,dts_conn2:connection;
dts_task:task;
dts_customtask:customtask;
dts_pumptask:datapumptask2;
dts_step:step;
begin
//package1.Execute;
//CoInitialize;
opackageold:=CoPackage.Create;
opackage:=opackageold as package2;
dts_conn:=opackage.Connections.new('Microsoft.Jet.OLEDB.4.0');
dts_conn.ID:=1;
dts_conn.DataSource:='c:/1.mdb';
dts_conn2:=opackage.Connections.New('Microsoft.Jet.OLEDB.4.0');
dts_conn2.ID:=2;
dts_conn2.DataSource:='c:/2.mdb';
opackage.Connections.Add(dts_conn);
opackage.Connections.Add(dts_conn2);
dts_step:=opackage.Steps.New;
dts_task:=opackage.Tasks.New('DTSDataPumpTask');
dts_task.Name:='Copy Data from 1.mdb to 2.mdb Task';
dts_customtask:=dts_task.CustomTask;
dts_pumptask:=dts_customtask as datapumptask2;
dts_pumptask.Name:='Copy Data from 1.mdb to 2.mdb Task';
dts_pumptask.SourceConnectionID:=1;
dts_pumptask.SourceSQLStatement:='select * from table1';
//dts_pumptask.SourceObjectName:='table1';
dts_pumptask.DestinationConnectionID:=2;
dts_pumptask.SourceSQLStatement:='select * from table1';
//dts_pumptask.DestinationObjectName:='table1';
dts_pumptask.ProgressRowCount:=100;
dts_pumptask.ProgressRowCount := 1000;
dts_pumptask.MaximumErrorCount := 0;
dts_pumptask.FetchBufferSize := 1;
dts_pumptask.UseFastLoad := True;
dts_pumptask.InsertCommitSize := 0;
dts_pumptask.ExceptionFileColumnDelimiter := '|';
dts_pumptask.ExceptionFileRowDelimiter := #13#10;
dts_pumptask.AllowIdentityInserts := False;
dts_pumptask.FirstRow := 0;
dts_pumptask.LastRow := 0;
dts_pumptask.FastLoadOptions := 2;
dts_pumptask.ExceptionFileOptions := 1;
dts_pumptask.DataPumpOptions := 0;
dts_step.Name:='LowerCaseStep';
dts_step.TaskName:=dts_pumptask.Name;
dts_step.ExecuteInMainThread:=true;
oCustomTask2_Trans_S1(dts_pumptask);
opackage.Tasks.Add(dts_task);
opackage.Steps.Add(dts_step);
opackage.Execute;
opackage.UnInitialize;
end;
恳请各位富翁帮帮忙看看;
最好能提供段可用的代码。
数据没有从源数据库导进目标数据库,目标数据库仍然为空。
procedure TForm1.Button1Click(Sender: TObject);
procedure oCustomTask2_Trans_S1(oCustomTask2: DataPumpTask2);
var
oTransformationOld: Transformation;
oTransformation: Transformation2;
begin
oTransformationOld := oCustomTask2.Transformations.New('DTS.DataPumpTransformCopy');
oTransformation := oTransformationOld as Transformation2;
oTransformation.Name := 'DirectCopyXform';
oTransformation.TransformFlags := 63;
oTransformation.ForceSourceBlobsBuffered := 0;
oTransformation.ForceBlobsInMemory := False;
oTransformation.InMemoryBlobSize := 1048576;
oTransformation.TransformPhases := 4;
oCustomTask2.Transformations.Add(oTransformation);
oTransformation := nil;
oTransformationOld := nil;
end;
var opackageold: package;
opackage: package2;
dts_conn,dts_conn2:connection;
dts_task:task;
dts_customtask:customtask;
dts_pumptask:datapumptask2;
dts_step:step;
begin
//package1.Execute;
//CoInitialize;
opackageold:=CoPackage.Create;
opackage:=opackageold as package2;
dts_conn:=opackage.Connections.new('Microsoft.Jet.OLEDB.4.0');
dts_conn.ID:=1;
dts_conn.DataSource:='c:/1.mdb';
dts_conn2:=opackage.Connections.New('Microsoft.Jet.OLEDB.4.0');
dts_conn2.ID:=2;
dts_conn2.DataSource:='c:/2.mdb';
opackage.Connections.Add(dts_conn);
opackage.Connections.Add(dts_conn2);
dts_step:=opackage.Steps.New;
dts_task:=opackage.Tasks.New('DTSDataPumpTask');
dts_task.Name:='Copy Data from 1.mdb to 2.mdb Task';
dts_customtask:=dts_task.CustomTask;
dts_pumptask:=dts_customtask as datapumptask2;
dts_pumptask.Name:='Copy Data from 1.mdb to 2.mdb Task';
dts_pumptask.SourceConnectionID:=1;
dts_pumptask.SourceSQLStatement:='select * from table1';
//dts_pumptask.SourceObjectName:='table1';
dts_pumptask.DestinationConnectionID:=2;
dts_pumptask.SourceSQLStatement:='select * from table1';
//dts_pumptask.DestinationObjectName:='table1';
dts_pumptask.ProgressRowCount:=100;
dts_pumptask.ProgressRowCount := 1000;
dts_pumptask.MaximumErrorCount := 0;
dts_pumptask.FetchBufferSize := 1;
dts_pumptask.UseFastLoad := True;
dts_pumptask.InsertCommitSize := 0;
dts_pumptask.ExceptionFileColumnDelimiter := '|';
dts_pumptask.ExceptionFileRowDelimiter := #13#10;
dts_pumptask.AllowIdentityInserts := False;
dts_pumptask.FirstRow := 0;
dts_pumptask.LastRow := 0;
dts_pumptask.FastLoadOptions := 2;
dts_pumptask.ExceptionFileOptions := 1;
dts_pumptask.DataPumpOptions := 0;
dts_step.Name:='LowerCaseStep';
dts_step.TaskName:=dts_pumptask.Name;
dts_step.ExecuteInMainThread:=true;
oCustomTask2_Trans_S1(dts_pumptask);
opackage.Tasks.Add(dts_task);
opackage.Steps.Add(dts_step);
opackage.Execute;
opackage.UnInitialize;
end;
恳请各位富翁帮帮忙看看;
最好能提供段可用的代码。