dbTalk Databases Forums  

assigning source file at runtime

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss assigning source file at runtime in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
san
 
Posts: n/a

Default assigning source file at runtime - 12-06-2006 , 04:00 AM






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_UseTrus tedConnection, , , ,
"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..


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: assigning source file at runtime - 12-06-2006 , 04:12 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

Quote:
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_UseTrus tedConnection, , , ,
"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..




Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.