Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 9th, 2008, 12:04 PM
Registered User
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default DTS ActiveX - Download file from an url(http://..)

Can anyone help me to automate the file download from a http url.
I hv set of files located in "http://remotesrvr:8080/datafiles/eachday/" with hyperlinks on each file. Manually I hv to access this url, right click the filename and download it to my local desk. We want to automate the process, by giving the source location as "http://remotesrvr:8080/datafiles/eachday/data_20080407.txt" and the destination cld be "c:\datafile\today\data_20080407.txt".
As it is not a FTP location or can't be mapped thru' network, finding it difficult to do it using DTS ActiveX script. I tried it by doing SCREENSCRAPPING, but it gives "out of memory" exception when the file is huge to read.
Ref the code snippet below,
'************************************************* ********************
' Visual Basic ActiveX Script
'************************************************* ********************
Dim objXmlHttp
Set objXmlHttp = CreateObject("Msxml2.XMLHttp")

Function Main()
    dim filesys, filetxt, getname, path, dest_file, file_name, src_url
    file_name = "data_20080407.txt"
    dest_file = "c:\datafile\" + file_name
    src_url = "http://remotesrvr:8080/datafiles/eachday/" + file_name

    objXmlHttp.Open "POST", src_url, False
    objXmlHttp.onreadystatechange = getref("HandleStateChange")

    if (len(objXmlHttp.responseText) > 1000) then
        Set filesys = CreateObject("Scripting.FileSystemObject")
        Set filetxt = filesys.CreateTextFile(dest_file, True)
        path = filesys.GetAbsolutePathName(dest_file)
        getname = filesys.GetFileName(path)
    end if

    Main = DTSTaskExecResult_Success
End Function

Function HandleStateChange()
    If (ObjXmlHttp.readyState = 4) Then
        'msgbox "Screenscrapping completed .."
    End If
End Function

In the above code "objXmlHttp.responseText" gives memory out of exception when the source file size is huge, as it is holding the entire file content in server memory. Need to find out a way to directly stream the source content to a destination location. Is there any way I could achieve this? highly appreciate anyone's immediate help. many thx in advance.


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change file path to http url cJeffreywang BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 0 July 25th, 2007 12:18 AM
Error: File path and URL http map differently cJeffreywang ASP.NET 1.0 and 1.1 Basics 4 March 27th, 2007 08:03 PM
Download a file from http location sarath_lal007 ASP.NET 1.0 and 1.1 Professional 1 February 17th, 2006 05:34 AM
Download file through HTTP KCUK Beginning VB 6 0 August 19th, 2005 07:20 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.