DTS导入的问题

不好意思先放下,解决了就撤下去
我在利用DTS导入SQL时,程序不出现错误,但是没有将需要的数据导入到sql中,大家帮我看看:
代码如下:
Button代码:
None.gif      string  strdespath = " bsee " ;
None.gif            
string  strsourcepath  = " c:\\File\\abc.XLS " ;
None.gif            
string  tablename = " OTHER_MainPTJob " ;            
None.gif            
string  strsql = " select  id  from [bsee].[dbo].[OTHER_MainPTJob] " ;
None.gif            AppExportData tryclass
= new  AppExportData(strsourcepath,strdespath,tablename,strsql);
None.gif            tryclass.ExportData();        
导入类:
None.gif      public   class  AppExportData
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
//DTS包对象
InBlock.gif
            public DTS.Package2Class ObjDTS;
InBlock.gif            
//源文件路径
InBlock.gif
            private string strSourceFilePath; 
InBlock.gif            
//目标文件路径 
InBlock.gif
            private string strDestinationFilePath;
InBlock.gif            
//导出数据的SQL语句
InBlock.gif
            private string strSQL;
InBlock.gif            
//目标表名
InBlock.gif
            private string strTableName;
InBlock.gif            
//得到目标列名
InBlock.gif
            private ArrayList arrDestinationColumns;
InBlock.gif            
//得到源数据列名
InBlock.gif
            private ArrayList arrSourceColumns;
InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif            
私有属性#region 私有属性
InBlock.gif            
private ArrayList SourceColumns
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
get
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return arrSourceColumns;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
set
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    arrSourceColumns 
= value;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 得到目标列名
ExpandedSubBlockEnd.gif            
/// </summary>

InBlock.gif            private ArrayList DestinationColumns
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
get 
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return arrDestinationColumns;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
set 
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    arrDestinationColumns 
= value;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif            
#endregion

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif            
公共属性#region 公共属性
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 目标表名
ExpandedSubBlockEnd.gif            
/// </summary>

InBlock.gif            public string TableName
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
get
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return strTableName;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
set 
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    strTableName 
= value;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 导出数据的SQL语句
ExpandedSubBlockEnd.gif            
/// </summary>

InBlock.gif            public string SQL
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
get
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return strSQL;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
set 
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    strSQL 
= value;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 源文件所在的路径
ExpandedSubBlockEnd.gif            
/// </summary>

InBlock.gif            public string SourceFilePath
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
get
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return strSourceFilePath;
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                
set
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    strSourceFilePath 
= value;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 目标文件所在的路径
ExpandedSubBlockEnd.gif            
/// </summary>

InBlock.gif            public string DestinationFilePath
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
get
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return strDestinationFilePath;
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                
set
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    strDestinationFilePath 
= value;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif            
#endregion

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 构造函数
ExpandedSubBlockEnd.gif            
/// </summary>

InBlock.gif            public AppExportData(string strsourcepath,string strdespath,string tablename,string strsql)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif
InBlock.gif                strTableName 
= "结果";
InBlock.gif                arrDestinationColumns 
= new ArrayList();
InBlock.gif                arrSourceColumns 
= new ArrayList();
InBlock.gif                strSourceFilePath
=strsourcepath;
InBlock.gif                strDestinationFilePath
=strdespath;
InBlock.gif                strTableName
=tablename;
InBlock.gif                strSQL
=strsql;                
ExpandedSubBlockEnd.gif            }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif            
导出的全过程#region 导出的全过程
InBlock.gif            
public bool ExportData()
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
try
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    ObjDTS 
= new DTS.Package2Class();
InBlock.gif
InBlock.gif                    
if ( this.arrDestinationColumns.Count == 0 || this.arrSourceColumns.Count == 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
if ( !this.GetColumns() )
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            
//showMessage( "没有获得数据,导出文件失败!");
InBlock.gif
                            return false;
ExpandedSubBlockEnd.gif                        }

ExpandedSubBlockEnd.gif                    }

InBlock.gif    
InBlock.gif                    
//新建一个新的DTS包,设置它的属性
InBlock.gif
                    ObjDTS.Name = "新建包";
InBlock.gif                    ObjDTS.Description 
= "DTS 包描述";
InBlock.gif                    ObjDTS.WriteCompletionStatusToNTEventLog 
= false;
InBlock.gif                    ObjDTS.FailOnError 
= false;
InBlock.gif                    ObjDTS.PackagePriorityClass 
= ( DTS.DTSPackagePriorityClass )2;
InBlock.gif                    ObjDTS.MaxConcurrentSteps 
= 4;
InBlock.gif                    ObjDTS.LineageOptions 
= 0;
InBlock.gif                    ObjDTS.UseTransaction 
= true;
InBlock.gif                    ObjDTS.TransactionIsolationLevel 
= ( DTS.DTSIsolationLevel )4096;
InBlock.gif                    ObjDTS.AutoCommitTransaction 
= true;
InBlock.gif                    ObjDTS.RepositoryMetadataOptions 
= 0;
InBlock.gif                    ObjDTS.UseOLEDBServiceComponents 
= true;
InBlock.gif                    ObjDTS.LogToSQLServer 
= false;
InBlock.gif                    ObjDTS.LogServerFlags 
= 0;
InBlock.gif                    ObjDTS.FailPackageOnLogFailure 
= false;
InBlock.gif                    ObjDTS.ExplicitGlobalVariables 
= false;
InBlock.gif                    ObjDTS.PackageType 
= 0;
InBlock.gif
InBlock.gif                    
//建立SQL的连接,设置其属性
InBlock.gif
                    DTS.Connection2 oConnection;
InBlock.gif                        
InBlock.gif                    
InBlock.gif                    
//建立导出数据库的连接,设置其属性
InBlock.gif
                    oConnection = ( DTS.Connection2 )ObjDTS.Connections.New("Microsoft.Jet.OLEDB.4.0");
InBlock.gif                    oConnection.ConnectionProperties.Item(
"Data Source").Value = this.strSourceFilePath;
InBlock.gif                    oConnection.ConnectionProperties.Item(
"Extended Properties").Value = "Excel 8.0;HDR=YES;";
InBlock.gif                    oConnection.Name 
= "连接2";
InBlock.gif                    oConnection.ID 
= 1;
InBlock.gif                    oConnection.Reusable 
= true;
InBlock.gif                    oConnection.ConnectImmediate 
= false;
InBlock.gif                    oConnection.DataSource 
= this.strSourceFilePath;
InBlock.gif                    oConnection.ConnectionTimeout 
= 60;
InBlock.gif                    oConnection.UseTrustedConnection 
= false;
InBlock.gif                    oConnection.UseDSL 
= false;
InBlock.gif                    
//将其加入DTS包中
InBlock.gif
                    ObjDTS.Connections.Add( ( DTS.Connection )oConnection );
InBlock.gif                    oConnection 
= null;
InBlock.gif
InBlock.gif
InBlock.gif                    oConnection 
=(DTS.Connection2) ObjDTS.Connections.New("SQLOLEDB");
InBlock.gif                    oConnection.ConnectionProperties.Item(
"Integrated Security").Value  = "SSPI";
InBlock.gif                    oConnection.ConnectionProperties.Item(
"Persist Security Info").Value = true;
InBlock.gif                    oConnection.ConnectionProperties.Item(
"Initial Catalog").Value = this.strDestinationFilePath;
InBlock.gif                    oConnection.ConnectionProperties.Item(
"Data Source").Value = "(local)";
InBlock.gif                    oConnection.ConnectionProperties.Item(
"Application Name").Value = "DTS 导入/导出向导";            
InBlock.gif                    oConnection.Name 
= "连接1";
InBlock.gif                    oConnection.ID 
= 2;
InBlock.gif                    oConnection.Reusable 
= true;
InBlock.gif                    oConnection.ConnectImmediate 
= false;
InBlock.gif                    oConnection.DataSource 
= "(local)";
InBlock.gif                    oConnection.ConnectionTimeout 
= 60;
InBlock.gif                    oConnection.Catalog 
=this.strDestinationFilePath;
InBlock.gif                    ObjDTS.Connections.Add( ( DTS.Connection)oConnection );
InBlock.gif                    oConnection 
= null;
InBlock.gif
InBlock.gif                
InBlock.gif                
InBlock.gif
InBlock.gif                    
//设置DTS执行的步骤
InBlock.gif
                    DTS.Step2 oStep;
InBlock.gif                    DTS.PrecedenceConstraint oPrecConstraint;  
InBlock.gif                    oStep 
= ( DTS.Step2 ) ObjDTS.Steps.New();
InBlock.gif                    
//创建表,设置属性
InBlock.gif
                    oStep.Name = "创建表 " + this.strTableName + " 步骤";
InBlock.gif                    oStep.Description 
= "创建表 "+ this.strTableName + " 步骤";
InBlock.gif                    oStep.ExecutionStatus 
= ( DTS.DTSStepExecStatus )1;
InBlock.gif                    oStep.TaskName 
= "创建表 " + this.strTableName + " 任务";
InBlock.gif                    oStep.CommitSuccess 
= false;
InBlock.gif                    oStep.RollbackFailure 
= false;
InBlock.gif                    oStep.ScriptLanguage 
= "VBScript";
InBlock.gif                    oStep.AddGlobalVariables 
= true;
InBlock.gif                    oStep.RelativePriority 
= ( DTS.DTSStepRelativePriority )3;
InBlock.gif                    oStep.CloseConnection 
= false;
InBlock.gif                    oStep.ExecuteInMainThread 
= false;
InBlock.gif                    oStep.IsPackageDSORowset 
= false;
InBlock.gif                    oStep.JoinTransactionIfPresent 
= false;
InBlock.gif                    oStep.DisableStep 
= false;
InBlock.gif                    oStep.FailPackageOnError 
= false;
InBlock.gif                    
//将其加入DTS包中
InBlock.gif
                    ObjDTS.Steps.Add( oStep );
InBlock.gif                    oStep 
= null;
InBlock.gif
InBlock.gif  
InBlock.gif                    
//设置数据导出的步骤 , 设置性属
InBlock.gif
                    oStep = ( DTS.Step2 )ObjDTS.Steps.New();
InBlock.gif                    oStep.Name 
= "Copy Data from 结果 to " + this.strTableName + " 步骤";
InBlock.gif                    oStep.Description 
= "Copy Data from 结果 to " + this.strTableName + " 步骤";
InBlock.gif                    oStep.ExecutionStatus 
= ( DTS.DTSStepExecStatus )1;
InBlock.gif                    oStep.TaskName 
= "Copy Data from 结果 to " + this.strTableName + " 任务";
InBlock.gif                    oStep.CommitSuccess 
= false;
InBlock.gif                    oStep.RollbackFailure 
= false;
InBlock.gif                    oStep.ScriptLanguage 
= "VBScript";
InBlock.gif                    oStep.AddGlobalVariables 
= true;
InBlock.gif                    oStep.RelativePriority 
= ( DTS.DTSStepRelativePriority )3;
InBlock.gif                    oStep.CloseConnection 
= false;
InBlock.gif                    oStep.ExecuteInMainThread 
= true;
InBlock.gif                    oStep.IsPackageDSORowset 
= false;
InBlock.gif                    oStep.JoinTransactionIfPresent 
= false;
InBlock.gif                    oStep.DisableStep 
= false;
InBlock.gif                    oStep.FailPackageOnError 
= false;
InBlock.gif                    
//将其添加到DTS包中
InBlock.gif
                    ObjDTS.Steps.Add( oStep );
InBlock.gif                    oStep 
= null;
InBlock.gif
InBlock.gif                    
//设置生成表的步骤
InBlock.gif
                    oStep = ( DTS.Step2 )ObjDTS.Steps.Item("Copy Data from 结果 to " + this.strTableName + " 步骤");
InBlock.gif                    oPrecConstraint 
= oStep.PrecedenceConstraints.New("创建表 " + this.strTableName + " 步骤");
InBlock.gif                    oPrecConstraint.StepName 
= "创建表 " + this.strTableName + " 步骤";
InBlock.gif                    oPrecConstraint.PrecedenceBasis 
= 0;
InBlock.gif                    oPrecConstraint.Value 
= 4;
InBlock.gif
InBlock.gif                    oStep.PrecedenceConstraints.Add( oPrecConstraint );
InBlock.gif                    oPrecConstraint 
= null;
InBlock.gif
InBlock.gif                    
//this.Task_Sub1(ObjDTS);
InBlock.gif
                    this.Task_Sub2(ObjDTS);
InBlock.gif    
InBlock.gif                    
//执行导出数据
InBlock.gif
                    ObjDTS.Execute();
InBlock.gif                    tracePackageError( ObjDTS );
InBlock.gif                    
return true;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
catch (Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return false;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    ObjDTS.UnInitialize();
InBlock.gif                    System.Runtime.InteropServices.Marshal.ReleaseComObject( ObjDTS );
InBlock.gif                    ObjDTS 
= null;
InBlock.gif                    GC.Collect();
InBlock.gif                    
this.arrDestinationColumns.Clear();
InBlock.gif                    
this.arrSourceColumns.Clear();
ExpandedSubBlockEnd.gif                }

InBlock.gif   
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif
InBlock.gif            
private void tracePackageError( DTS.Package2Class oPackage)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
int ErrorCode;
InBlock.gif                
string ErrorSource;
InBlock.gif                
string ErrorDescription;
InBlock.gif                
string ErrorHelpFile;
InBlock.gif                
int ErrorHelpContext;
InBlock.gif                
string ErrorIDofInterfaceWithError;                               
InBlock.gif                
forint i = 1 ; i < oPackage.Steps.Count ; i ++ )                
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if ( oPackage.Steps.Item(i).ExecutionResult == DTS.DTSStepExecResult.DTSStepExecResult_Failure )
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        oPackage.Steps.Item(i).GetExecutionErrorInfo(
out ErrorCode,out ErrorSource,out ErrorDescription,out ErrorHelpFile,out ErrorHelpContext,out ErrorIDofInterfaceWithError);
InBlock.gif                        
//添加抛出异常语句
ExpandedSubBlockEnd.gif
                    }

ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }
 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 创建表
InBlock.gif            
/// </summary>
ExpandedSubBlockEnd.gif            
/// <param name="goPackage">DTS包对象</param>

InBlock.gif            private void Task_Sub1( DTS.Package2Class ObjDTS )
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                DTS.Task oTask;
InBlock.gif   
InBlock.gif                DTS.ExecuteSQLTask2 oCustomTask1;
InBlock.gif                oTask 
= ObjDTS.Tasks.New("DTSExecuteSQLTask");
InBlock.gif                oTask.Name 
= "创建表 " + this.strTableName + " 任务";
InBlock.gif                oCustomTask1 
= ( DTS.ExecuteSQLTask2) oTask.CustomTask;
InBlock.gif
InBlock.gif                oCustomTask1.Name 
= "创建表 " + this.strTableName + " 任务";
InBlock.gif                oCustomTask1.Description 
= "创建表 " + this.strTableName + " 任务";
InBlock.gif                oCustomTask1.SQLStatement 
= "CREATE TABLE `" + this.strTableName + "` (" + "\n";
InBlock.gif
InBlock.gif                
//arrDestinationColumns[0]="管理号";
InBlock.gif
                forint i = 0 ; i < this.arrDestinationColumns.Count ; i ++ )
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if ( i == this.arrDestinationColumns.Count - 1 )
InBlock.gif                        oCustomTask1.SQLStatement 
= oCustomTask1.SQLStatement + "[" + this.arrDestinationColumns[i].ToString() +"]  VarChar(50) " + "\n";
InBlock.gif                    
else
InBlock.gif                        oCustomTask1.SQLStatement 
= oCustomTask1.SQLStatement + "[" + this.arrDestinationColumns[i].ToString() +"]  VarChar(50), " + "\n";
ExpandedSubBlockEnd.gif                }

InBlock.gif   
InBlock.gif                oCustomTask1.SQLStatement 
= oCustomTask1.SQLStatement + ")";
InBlock.gif                oCustomTask1.ConnectionID 
= 2;
InBlock.gif                oCustomTask1.CommandTimeout 
= 0;
InBlock.gif                oCustomTask1.OutputAsRecordset 
= false;
InBlock.gif 
InBlock.gif                ObjDTS.Tasks.Add( oTask );
InBlock.gif                oCustomTask1 
= null;
InBlock.gif                oTask 
= null;
ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 执行导出的SQL语句
InBlock.gif            
/// </summary>
ExpandedSubBlockEnd.gif            
/// <param name="ObjDTS">DTS包对象</param>

InBlock.gif            private void Task_Sub2( DTS.Package2Class ObjDTS )
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                DTS.Task oTask;
InBlock.gif   
InBlock.gif                DTS.DataPumpTask2 oCustomTask2;
InBlock.gif                oTask 
= ObjDTS.Tasks.New("DTSDataPumpTask");
InBlock.gif                oTask.Name 
= "Copy Data from 结果 to " + this.strTableName + " 任务";
InBlock.gif                oCustomTask2 
= (DTS.DataPumpTask2 )oTask.CustomTask;
InBlock.gif
InBlock.gif                oCustomTask2.Name 
= "Copy Data from 结果 to " + this.strTableName + " 任务";
InBlock.gif                oCustomTask2.Description 
= "Copy Data from 结果 to " + this.strTableName + " 任务";
InBlock.gif                oCustomTask2.SourceConnectionID 
= 1;
InBlock.gif                oCustomTask2.SourceSQLStatement 
= this.strSQL;   
InBlock.gif                oCustomTask2.DestinationConnectionID 
= 2;                
InBlock.gif                oCustomTask2.DestinationObjectName 
=  "[bsee].[dbo].["+this.strTableName+"]";                
InBlock.gif                oCustomTask2.ProgressRowCount 
= 1000;
InBlock.gif                oCustomTask2.MaximumErrorCount 
= 0;
InBlock.gif                oCustomTask2.FetchBufferSize 
= 1;
InBlock.gif                oCustomTask2.UseFastLoad 
= true;
InBlock.gif                oCustomTask2.InsertCommitSize 
= 0;
InBlock.gif                oCustomTask2.ExceptionFileColumnDelimiter 
= "|";
InBlock.gif                oCustomTask2.ExceptionFileRowDelimiter 
= @"\n";
InBlock.gif                oCustomTask2.AllowIdentityInserts 
= false;
InBlock.gif                oCustomTask2.FirstRow 
= 0;
InBlock.gif                oCustomTask2.LastRow 
= 0;
InBlock.gif                oCustomTask2.FastLoadOptions 
= ( DTS.DTSFastLoadOptions )2;
InBlock.gif                oCustomTask2.ExceptionFileOptions 
= ( DTS.DTSExceptionFileOptions )1;
InBlock.gif                oCustomTask2.DataPumpOptions 
= 0;
InBlock.gif 
InBlock.gif                
this.oCustomTask2_Trans_Sub1( oCustomTask2 );
InBlock.gif  
InBlock.gif  
InBlock.gif                ObjDTS.Tasks.Add( oTask );
InBlock.gif                oCustomTask2 
= null;
InBlock.gif                oTask 
= null;
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 设置导出的源列和目标列的对应关系
InBlock.gif            
/// </summary>
ExpandedSubBlockEnd.gif            
/// <param name="oCustomTask2"></param>

InBlock.gif            private void oCustomTask2_Trans_Sub1( DTS.DataPumpTask2 oCustomTask2 )
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
InBlock.gif                DTS.Transformation2 oTransformation;
InBlock.gif                DTS.Properties oTransProps;
InBlock.gif                DTS.Column oColumn;
InBlock.gif                oTransformation 
= ( DTS.Transformation2 )oCustomTask2.Transformations.New("DTS.DataPumpTransformCopy");
InBlock.gif                oTransformation.Name 
= "DirectCopyXform";
InBlock.gif                oTransformation.TransformFlags 
= 63;
InBlock.gif                oTransformation.ForceSourceBlobsBuffered 
= ( DTS.DTSForceMode )1;
InBlock.gif                oTransformation.ForceBlobsInMemory 
= false;
InBlock.gif                oTransformation.InMemoryBlobSize 
= 1048576;
InBlock.gif                oTransformation.TransformPhases 
= 4;
InBlock.gif  
InBlock.gif                
InBlock.gif                oColumn 
= oTransformation.SourceColumns.New("id" , 1);
InBlock.gif                oColumn.Name 
= "id";
InBlock.gif                oColumn.Ordinal 
= 1;
InBlock.gif                oColumn.Flags 
= 102;
InBlock.gif                oColumn.Size 
= 255;
InBlock.gif                oColumn.DataType 
= 130;
InBlock.gif                oColumn.Precision 
= 0;
InBlock.gif                oColumn.NumericScale 
= 0;
InBlock.gif                oColumn.Nullable 
= true;
InBlock.gif            
InBlock.gif                oTransformation.SourceColumns.Add( oColumn );
InBlock.gif                oColumn 
= null;
InBlock.gif    
InBlock.gif        
InBlock.gif
InBlock.gif                oColumn 
= oTransformation.DestinationColumns.New("id" , 1);
InBlock.gif                oColumn.Name 
= "id";
InBlock.gif                oColumn.Ordinal 
= 1;
InBlock.gif                oColumn.Flags 
= 24;
InBlock.gif                oColumn.Size 
= 10;
InBlock.gif                oColumn.DataType 
= 129;
InBlock.gif                oColumn.Precision 
= 0;
InBlock.gif                oColumn.NumericScale 
= 0;
InBlock.gif                oColumn.Nullable 
= false;
InBlock.gif            
InBlock.gif                oTransformation.DestinationColumns.Add( oColumn );
InBlock.gif                oColumn 
= null;
InBlock.gif                oTransProps 
= oTransformation.TransformServerProperties;
InBlock.gif                oTransProps 
= null;
InBlock.gif
InBlock.gif                oCustomTask2.Transformations.Add( oTransformation ); 
InBlock.gif                oTransformation 
= null;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif            
#endregion

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
/**//// <summary>
InBlock.gif            
/// 在SQL语句中得到目标表的列名 , 本来是想根据SQL语句来决定列名,没有找到高效的分解SQL语句的方法。
ExpandedSubBlockEnd.gif            
/// </summary>

InBlock.gif            private bool GetColumns()
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
try
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{    
InBlock.gif                    SqlConnection conn
=new SqlConnection("server=.;uid=sa;pwd=;database=bsee");
InBlock.gif                    SqlDataAdapter da
=new SqlDataAdapter(strSQL,conn);
InBlock.gif                    DataSet ds 
= new DataSet();    
InBlock.gif                    da.Fill(ds,
"qqq");                                    
InBlock.gif                    
for ( int i = 0; i < ds.Tables[0].Columns.Count; i++ )
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
this.arrDestinationColumns.Add(ds.Tables[0].Columns[i].ColumnName );
InBlock.gif                        
this.arrSourceColumns.Add(ds.Tables[0].Columns[i].ColumnName);
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
return true;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
catch 
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
return false;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }
 
ExpandedBlockEnd.gif        }

数据库名“bsee”,表名:OTHER_MainPTJob,表内只有一个字段:id

转载于:https://www.cnblogs.com/gjahead/archive/2007/04/17/717295.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值