all groups > sql server dts > december 2006 >
You're in the

sql server dts

group:

assigning source file at runtime


assigning source file at runtime san
12/6/2006 2:00:07 AM
sql server dts:
hi,

i have made a package in SQL SERVER 2000 and then execute it from
vb.net

the source file is .txt file and the destination is sql table.
now the source file's path is to be given at runtime thru vb.net code.

i used the following code:




Dim dtsImport1 As New DTS.Package2

Dim stp1 As DTS.Step

With dtsImport1

.LoadFromSQLServer("servername", "", "",
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, , , ,
"insert_pkg")

.Connections.Item(1).DataSource = "C:\" +textbox1.text+
"\filename.txt"

.FailOnError = True
.Execute()
End With




but it is giving error that package execution failed.....copy step
failed...



plzzzzzz can any1 tell me wats wrong with this code and how should i
assign filepath at runtime while i have already given a path to
connection1 when making the package..
Re: assigning source file at runtime Allan Mitchell
12/6/2006 10:12:38 PM
Hello san,
Personally I prefer my Connections named. like this and not their ordinal
number.

pkg.Connections.Item("Name Of Connection").DataSource = Whatever


That said.

You do not give us much of an error message. If you take out the assignment
of the flat file to the package does the code all work?
Have you debugged what it is exactly you are sending to the Connection just
in case it is not what you think?
have you tried executing with events and trapping an error?

www.SQLDEV.Net has a most excellent example of this


Regards

Allan Mitchell
Konesans Ltd
T +44 7966 476 572
F +44 2071 008 479
http://www.konesans.com

[quoted text, click to view]

AddThis Social Bookmark Button