If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > DTS Object

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-12-03, 08:45
alemao_floripa alemao_floripa is offline
Registered User
 
Join Date: Feb 2003
Posts: 1
DTS Object

I want to make some test with BulkInsertTask Object and VB. I read the online documentation from Microsoft(http://msdn.microsoft.com/library/de...tasks_3b5g.asp) and wrote a simple script like this:

-------------------------------

Public Sub Main()
'initialize Payroll table in DTS_UE db with bulk data
Dim objPackage As DTS.Package2
Dim objConnect As DTS.Connection2
Dim objStep As DTS.Step
Dim objTask As DTS.Task
Dim objBulkCopy As DTS.BulkInsertTask

Set objPackage = New DTS.Package

'create database connection
Set objConnect = objPackage.Connections.New("SQLOLEDB.1")
With objConnect
.ID = 1
.DataSource = "BIBLION"
.UseTrustedConnection = True
End With
objPackage.Connections.Add objConnect
'create step and task, specify data file and format
Set objStep = objPackage.Steps.New
Set objTask = objPackage.Tasks.New("DTSBulkInsertTask")
Set objBulkCopy = objTask.CustomTask
With objBulkCopy
.Name = "BulkInsTask"
.DataFile = "c:\temp\teste.txt"
.ConnectionID = 1
.DestinationTableName = "tb_teste..teste"
.FieldTerminator = "|"
.RowTerminator = "\r\n"
End With

'link step to task to package, run package
objStep.TaskName = objBulkCopy.Name
objStep.Name = "BulkInsStep"
With objPackage
.Steps.Add objStep
.Tasks.Add objTask
.FailOnError = True

.Execute
End With
End Sub

------------------------------------------

An error occurs:
"Package failed because step 'BulkInsStep' failed"

I`m using a remote SQL Server 2000.

Someone can help me ???
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On