Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Question on passing Username and Password to my script task when downloading a file from a website.

$
0
0

Hi,

I am using a Script task and http Connection manager to get a zipfile from some websites.

My code is working fine for the sites which doesn't need username and password to be passed.

Can you help me modify my code so that I can pass username and password also.

FYI..

Below is the code I am using.

I am using the DownloadURL in the ReadOnlyVariables to pass my URL.

I also have my Username and Password Variables created.

        public void Main()

        {

            // TODO: Add your code here

            bool fireAgain = true;

            Dts.Events.FireInformation(0, "Download File""Start downloading " + Dts.Variables["DownloadURL"].Value.ToString(), string.Empty, 0,ref fireAgain);

 

            // Create a webclient to download a file

            WebClient mySSISWebClient = new WebClient();

 

            //Download file and use the Flat File Connectionstring

            // to save the file (and replace the existing file)

            mySSISWebClient.DownloadFile(Dts.Variables["DownloadURL"].Value.ToString(), Dts.Connections["myProductFile"].ConnectionString);

 

            // Logging end of download

            Dts.Events.FireInformation(0, "Download File""Finished downloading " + Dts.Connections["myProductFile"].ConnectionString, string.Empty, 0, ref fireAgain);

 

            // Quit Script Task succesful

            Dts.TaskResult = (int)ScriptResults.Success;

            //Dts.TaskResult = (int)ScriptResults.Success;

            mySSISWebClient.DownloadFile

        }


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>