[quoted text, click to view] "kiran" <kiran.gazz@gmail.com> wrote:
> hi John,
> The soln is given below.
> ------------------------------------------------------------------------------
> " Public Sub Main()
>
> Dim vs As Variables
> Dts.VariableDispenser.LockForRead("g_str_server")
> Dts.VariableDispenser.LockForRead("g_str_username")
> Dts.VariableDispenser.LockForRead("g_str_password")
> Dts.VariableDispenser.LockForRead("g_str_databasename")
> Dts.VariableDispenser.LockForRead("g_str_connectiontype")
> Dts.VariableDispenser.GetVariables(vs)
> Dts.Connections("MD").ConnectionString = "Data Source=" &
> vs("g_str_server").Value.ToString() & ";User ID=" &
> vs("g_str_username").Value.ToString() & ";Pwd=" &
> vs("g_str_password").Value.ToString() & ";Initial Catalog=" &
> vs("g_str_databasename").Value.ToString() & ";Provider=SQLNCLI.1;Auto
> Translate=False;"
> Dts.Connections("MD").AcquireConnection(Nothing)
> Dts.TaskResult = Dts.Results.Success
> End Sub
>
> --- NOTE :
> 2> Create the OLE DB Cnnection In conn manager (HEre I have named it ad
> MD for that OLEDB Conn) .
> 1> Variables prifixed with "g_" are global variables and MD in
> "Dts.Connections("MD")" is the name of the OLEDB Connection manager
> Defined by the developer in Connection managers.
I think you interpreted the reverse of what I was asking. It appears from
the above that you are configuring an existing connection manager from
connection settings in package variables.
What I need is this: The package already has an OLEDB connection manager
(not necessarily talking to SQL Server!) that is configured via the standard
SSIS XML configuration file mechanism, and works for all of the non-script
tasks that interact with the database (e.g. an OLEDB query task).
What I need is to be able to look at that connection manager from within a
script task, and create a connection that talks to the same database so that
the script task can perform database operations.
I don't want to take the connection configuration information from package
variables. That's the hack I'm using right now, and I'd like something more
elegant, if possible.
Unfortunately, looking at the connection manager's ConnectionString property
isn't going to work as the database password is stripped off it.
Also unfortunately, according to the documentation AcquireConnection() does
not work at all for OLEDB connection managers, only ADO.NET connection
managers. How are you getting it to work in your example? (Remember to
distinguish between an OLEDB connection manager and an ADO.NET connection
manager that happens to be talking to an OLEDB data source...)
And that code looks like scripting for a control flow script task. The Dts
object doesn't exists in data flow script tasks, and that's where I need to
do this. Sorry for not making that clear in my initial post.
Thanks for your suggestion, though!
--
John Hardin KA7OHZ
Senior Applications Developer, RetailCRM Development
web:
http://www.epicor.com voice: (425) 672-1304
fax: (425) 672-0192
email: <jhardin@epicor.com>
EPICOR|CRS Retail Solutions Division
3400 188th Street SW, Suite 185
Lynnwood, WA 98037 USA
Worldwide Headquarters 18200 Von Karman, Suite 1000, Irvine CA 92612 USA
------------------------------------------------------------------------
The first time I saw a bagpipe, I thought the player was torturing an
octopus. I was amazed they could scream so loudly.
------------------------------------------------------------------------