Set the package to fail on first error
This code works for me and raises the following error if the file does not
exist
Step 'DTSStep_DTSDataPumpTask_1' failed
Step Error Source: Microsoft Data Transformation Services Flat File Rowset
Provider
Step Error Description:Error opening datafile: The system cannot find the
file specified.
Code:
Try
dtsPackage = New DTS.Package
dtsPackage.LoadFromSQLServer("LocalServer", , ,
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrus tedConnection, , , ,
"ChangeTextFileSourceName")
con = dtsPackage.Connections.Item("TextFileSource")
con.DataSource = Me.txtTextFileConnectionName.Text
'Fail on first error
dtsPackage.FailOnError = True
dtsPackage.Execute()
dtsPackage.UnInitialize()
Catch eX As Exception
MessageBox.Show("Exception raised in calling package: " & eX.Message)
End Try
--
----------------------------
Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"fabian" <fabianbg (AT) navegalia (DOT) com> wrote
Quote:
Hi, I've got this code:
dim pkg As DTS.Package
pkg = New DTS.Package
Dim oconn As DTS.Connection
Dim v As String
pkg.LoadFromSQLServer("server", "sa", "sa", _
DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
"", "", "", "ImportText", Nothing)
oconn = pkg.Connections.Item("Texto")
oconn.DataSource = "c:\bcp.txt"
pkg.Execute()
The code seems correct because it doesn't throw any exception but it
doesn't
import any data to the table. Is there anything wrong? |