Dynamically Changing Database name in Connection

  • This is my code and it will be executed in a loop

    Set conn = DTSGlobalVariables.Parent.Connections("DDS_Connection")

    ' On every iteration the value for [DTSGlobalVariables("CountryCode").Value] will be different.

    conn.ConnectionProperties("Initial Catalog").Value = "EEI_"&Trim(DTSGlobalVariables("CountryCode").Value)&"_DDS"

    MsgBox conn.ConnectionProperties("Initial Catalog").Value

    set conn = nothing

    Main = DTSTaskExecResult_Success

    Do i need to do anything more ? because the execute sql task after this is considering only the value comes in the first iteration.

    How to activate the button "Refresh" in Connection Properties window [near dbname] using VB script?

    **********Very very urgent

    Any suggestions or solutions will be much appreciable....

  • Sounds to me like either you're not executing the loop correctly or the CountryCode global variable value isn't being updated like you expect to be.

    How is CountryCode being populated and where is your loop executed?

  • Thanks for your reply,

    Please find the attached doc. i believeit will help you to understand the process I follow. To change the database name for the connection DDS_Connection [ref attached doc], i am using Dynamic properties task. It also change the dbname property of the dds_connection. but the problem is the Start_Log an execute sql task is suppose to put insert in all the databases that changes during the iteration process. Inspite of that it does all the insert to the database that come during the 1st iteration.

    I need help at this point. I want to Programmatically activate the Button "Refresh" in Connection Properties window. I strongly believe that, if I activate or refresh the connection after it change its dbname in every iteration, the problem will be solved.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply