dbTalk Databases Forums  

Change Connection Dynamically

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


Discuss Change Connection Dynamically in the microsoft.public.sqlserver.dts forum.



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

Default Change Connection Dynamically - 02-17-2004 , 11:05 AM






I have seen the example on http://www.sqldts.com, but would like more
clarification.
Please show how to connect to a DTS package on the server and then
change the connection path and file name of the excel file that
contains the data to be loaded into the table. I am not getting how
the Global Variable stuff works.

Is there an object list to the DTS package as well?

I am using vbscript. Can this be done using dtsrun.exe.

Thanks!

Please post answer to group.

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Change Connection Dynamically - 02-17-2004 , 11:40 AM






In message <2f691c82.0402170905.69e61e76 (AT) posting (DOT) google.com>, Paul
Muller <muller.paul (AT) principal (DOT) com> writes
Quote:
I have seen the example on http://www.sqldts.com, but would like more
clarification.
Please show how to connect to a DTS package on the server and then
change the connection path and file name of the excel file that
contains the data to be loaded into the table. I am not getting how
the Global Variable stuff works.

Is there an object list to the DTS package as well?

I am using vbscript. Can this be done using dtsrun.exe.

Thanks!

Please post answer to group.
The object model is documented in Books Online.

One way of coping with changing paths and other parameters is to design
the package such that it reads these properties at run-time from an
external source. The simplest way to do this is with a Dynamic
Properties Task. Sometimes this task can be a bit limited so you resort
to script, but the principle is the same.

Global variables are often used a half-way house for this information.

I would not recommend you make changes to the package when ever
something in your environment changes, rather design the package so that
it refreshes the information at run-time.

As above the package can read from an external source, or depending on
your execution method you can pass values in as part of that. If
executing through the object model then you can set task properties or
global variables before calling the execute method.

If using DTSRUN then look at the /A parameter as a neat way of setting a
global variable. The package must be designed to use the global variable
of course.

I personally combine the DTSRUN /A with reading from an external source
for my packages. For every package I schedule I always pass in a server
name. I assume SQL security since all my scheduled execute on a SQL
Server box, and all of them have a common DB with a table containing
environment specific settings. Every package then uses the server
(DTSRUN set global variable) to lookup what that specific package
requires in by common DB table.


Any help?

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #3  
Old   
Paul Muller
 
Posts: n/a

Default Re: Change Connection Dynamically - 02-18-2004 , 08:56 AM



Darren Green <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
In message <2f691c82.0402170905.69e61e76 (AT) posting (DOT) google.com>, Paul
Muller <muller.paul (AT) principal (DOT) com> writes
I have seen the example on http://www.sqldts.com, but would like more
clarification.
Please show how to connect to a DTS package on the server and then
change the connection path and file name of the excel file that
contains the data to be loaded into the table. I am not getting how
the Global Variable stuff works.

Is there an object list to the DTS package as well?

I am using vbscript. Can this be done using dtsrun.exe.

Thanks!

Please post answer to group.

The object model is documented in Books Online.

One way of coping with changing paths and other parameters is to design
the package such that it reads these properties at run-time from an
external source. The simplest way to do this is with a Dynamic
Properties Task. Sometimes this task can be a bit limited so you resort
to script, but the principle is the same.

Global variables are often used a half-way house for this information.

I would not recommend you make changes to the package when ever
something in your environment changes, rather design the package so that
it refreshes the information at run-time.

As above the package can read from an external source, or depending on
your execution method you can pass values in as part of that. If
executing through the object model then you can set task properties or
global variables before calling the execute method.

If using DTSRUN then look at the /A parameter as a neat way of setting a
global variable. The package must be designed to use the global variable
of course.

I personally combine the DTSRUN /A with reading from an external source
for my packages. For every package I schedule I always pass in a server
name. I assume SQL security since all my scheduled execute on a SQL
Server box, and all of them have a common DB with a table containing
environment specific settings. Every package then uses the server
(DTSRUN set global variable) to lookup what that specific package
requires in by common DB table.


Any help?
Darren,

Thanks that helped.

Question when I send a bogus path name to the package
-a "FilePath":"8"="f:\Package_TST.xls", sometimes it works and
sometimes it does not. I would expect it to fail every time?


Reply With Quote
  #4  
Old   
Darren Green
 
Posts: n/a

Default Re: Change Connection Dynamically - 02-18-2004 , 10:02 AM




"Sending" the path is just setting a global variable, so that in itself will
not fail since it is just passing through a string. If the package is setup
to read the global variable as a path and use it then I would expect it to
always fail when you pass an invalid path. If it doesn't then check you are
setting the correct global variable, note names are case sensitive, and that
you are actually using it every time.For it to inconsistent there must be
some inconsistency in the way you are using the variable in the package.


--
Darren Green
http://www.sqldts.com

"Paul Muller" <muller.paul (AT) principal (DOT) com> wrote

<snip>
Quote:
Question when I send a bogus path name to the package
-a "FilePath":"8"="f:\Package_TST.xls", sometimes it works and
sometimes it does not. I would expect it to fail every time?



Reply With Quote
  #5  
Old   
Paul Muller
 
Posts: n/a

Default Re: Change Connection Dynamically - 02-18-2004 , 07:43 PM



When I put the bogus path the default file path still existed, is it
possible that if it did not find the passed in path it the defaults to
the default path? When I deleted the file that was the default the
path the file failed consistently, when I passed the bogus path. Is it
possible to remove the default path and connection so it for sure
always read the -a switch?

Thanks so much!



"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
"Sending" the path is just setting a global variable, so that in itself will
not fail since it is just passing through a string. If the package is setup
to read the global variable as a path and use it then I would expect it to
always fail when you pass an invalid path. If it doesn't then check you are
setting the correct global variable, note names are case sensitive, and that
you are actually using it every time.For it to inconsistent there must be
some inconsistency in the way you are using the variable in the package.


--
Darren Green
http://www.sqldts.com

"Paul Muller" <muller.paul (AT) principal (DOT) com> wrote in message
news:2f691c82.0402180656.47af8ab4 (AT) posting (DOT) google.com...
snip
Question when I send a bogus path name to the package
-a "FilePath":"8"="f:\Package_TST.xls", sometimes it works and
sometimes it does not. I would expect it to fail every time?

Reply With Quote
  #6  
Old   
Darren Green
 
Posts: n/a

Default Re: Change Connection Dynamically - 02-19-2004 , 02:16 AM




"Paul Muller" <muller.paul (AT) principal (DOT) com> wrote

Quote:
When I put the bogus path the default file path still existed, is it
possible that if it did not find the passed in path it the defaults to
the default path?
From a variable level no. From a connection level no.

When I deleted the file that was the default the
Quote:
path the file failed consistently, when I passed the bogus path. Is it
possible to remove the default path and connection so it for sure
always read the -a switch?
No. You remove the variable value by ovewriting it witha another. Based on
the behaviour you have described it seems to me that the variable is not
being passed on to the connection within your package. Investigate the
package again, without bothering with /A. If that works, then I'd suggest
that your /A command is not matching the variable you think it is.

Perhaps add a script task that enumertes all variables and logs or MsgBox's
the names and values to confirm at run-time.


Quote:
Thanks so much!



"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in
message news:<#rhDAjj9DHA.2416 (AT) TK2MSFTNGP10 (DOT) phx.gbl>...
"Sending" the path is just setting a global variable, so that in itself
will
not fail since it is just passing through a string. If the package is
setup
to read the global variable as a path and use it then I would expect it
to
always fail when you pass an invalid path. If it doesn't then check you
are
setting the correct global variable, note names are case sensitive, and
that
you are actually using it every time.For it to inconsistent there must
be
some inconsistency in the way you are using the variable in the package.


--
Darren Green
http://www.sqldts.com

"Paul Muller" <muller.paul (AT) principal (DOT) com> wrote in message
news:2f691c82.0402180656.47af8ab4 (AT) posting (DOT) google.com...
snip
Question when I send a bogus path name to the package
-a "FilePath":"8"="f:\Package_TST.xls", sometimes it works and
sometimes it does not. I would expect it to fail every time?



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.