How to write a DTS package using C# ?
Stella, you can add a COM reference in your project to the Microsoft DTS
package library. The IDE will take care of wrapping the COM object so that
you can use it from managed code. Once you have that reference you will be
able to convert your VB code to C# without a problem. If you run into
something specific let us know.
--
Greg
http://www.claritycon.com/
Quote:
> I want to write a DTS package using C# instead of saving a
> package at SQL server. My codes written
> in VB as below. Can you tell me how to change to C#?
> Thanks!!
> Public goPackage As DTS.Package2
> Dim oCustomTask1 As DTS.DataPumpTask2
> Dim oTask As DTS.Task
> Set oTask = goPackage.Tasks.New("DTSDataPumpTask")
> Set oCustomTask1 = oTask.CustomTask
> oCustomTask1.Name = "DTSTask_DTSDataPumpTask_1"
> oCustomTask1.Description = "Transfer Data"
> oCustomTask1.SourceConnectionID = 1
> oCustomTask1.SourceSQLStatement = "select * from table1"
> oCustomTask1.DestinationConnectionID = 2
> oCustomTask1.DestinationObjectName = "[TEST].[dbo].
> [table2]"
> oCustomTask1.ProgressRowCount = 1000
> oCustomTask1.MaximumErrorCount = 0
> oCustomTask1.FetchBufferSize = 1
> oCustomTask1.UseFastLoad = True
> oCustomTask1.InsertCommitSize = 0
> oCustomTask1.ExceptionFileColumnDelimiter = "|"
> oCustomTask1.ExceptionFileRowDelimiter = vbCrLf
> oCustomTask1.AllowIdentityInserts = False
> oCustomTask1.FirstRow = "0"
> oCustomTask1.LastRow = "0"
> oCustomTask1.FastLoadOptions = 2
> oCustomTask1.ExceptionFileOptions = 1
> oCustomTask1.DataPumpOptions = 0
> goPackage.Tasks.Add oTask
> Set oCustomTask1 = Nothing
> Set oTask = Nothing
> -Stella