SQL Server Performance

Download file from Internet

Discussion in 'SQL Server DTS-Related Questions' started by mguerrero, Feb 5, 2007.

  1. mguerrero New Member

    Hi all,

    I'm being asked to create a scheduled DTS package that download a file from a http site, for example http:/www.problem.com/file.exe

    I've found solutions for this but when you have a FTP site.

    Any help will be appreciated!

    Thanks!

    Marcela

  2. MohammedU New Member

    http://groups.google.com/group/microsoft.public.sqlserver.programming/browse_thread/thread/6a0f200b10e61b8c/0d60f280eec4a73c?lnk=st&q=how+to+download+file+from+http+site&rnum=2&hl=en#0d60f280eec4a73c

    Read the above thread to get the answer...

    MohammedU.
    Moderator
    SQL-Server-Performance.com
  3. mguerrero New Member

    Thanks!!

    I found another problem that was the proxy.

    This is the code I used to solve that.

    I hope it helps to anybody that have the same problem.

    Regards,

    '************************************************************************
    ' Visual Basic ActiveX Script"
    '************************************************************************
    Function Main()

    Dim url, xmlhttp, responseBody
    url = "http://www.iii.com.ar/file.exe"
    Set xmlhttp = CreateObject("Msxml2.XMLHTTP.3.0")
    xmlhttp.Open "GET", url, False, "userproxy", "passproxy"
    xmlhttp.Send

    responseBody = xmlhttp.responseBody
    Set xmlhttp = Nothing
    Dim oADOStream
    Set oADOStream = CreateObject("ADODB.Stream")
    oADOStream.Type = 1 '(binary)
    oADOStream.Mode = 3 '(read / write)
    oADOStream.Open
    oADOStream.Write responseBody
    oADOStream.SaveToFile "c:somefile.zip"
    oADOStream.Close
    Set oADOStream = nothing

    Main = DTSTaskExecResult_Success
    End Function


Share This Page