By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,257 Members | 925 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,257 IT Pros & Developers. It's quick & easy.

a97 - problem transfer file from server with https

P: n/a
Hi NG,

I used the Internet Data Transfer Library of Dev Ashish found at
http://www.mvps.org/access/modules/mdl0037.htm to transfer text files from
a server with HTTPS in my old Ms Access 97 application.

'----snip----
Sub TestHTTP()
On Error GoTo ErrHandler
Dim objHTTP As InetTransferLib.HTTP
Const conTARGET = "https://ip.of.my.server/PathToMyFile/MyFile.csv"

Set objHTTP = New InetTransferLib.HTTP
With objHTTP
.HttpURL = conTARGET
.DestinationFile = "c:\MyFile.csv"
If .FileExists Then .OverwriteTarget = True
.ConnectToHTTPHost
.WriteHTTPDataToFile
End With
ExitHere:
On Error Resume Next
Set objHTTP = Nothing
Call SysCmd(acSysCmdRemoveMeter)
Exit Sub
ErrHandler:
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly,
Err.Source
Resume ExitHere
End Sub

This code was running fine for months - I did not changed anything but for
a couple of days I receive an error 6 - overflow message when
..WriteHTTPDataToFile is in progress.

The file size of MyFile.csv is about 100-250kb...

I tried to use the microsoft internet transfer control activex v6.0 but
with no success... ;-(

Any help or sample code is welcome

Regards

Hanspeter
Jan 6 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
IIRC there is a bug in the INetTransferLib.

In the WriteHTTPDataToFile and the WriteFTPDataToFile ther is a line which
looks like this
Call apiWriteFile(hFile, abytData(0), MAX_CHUNK, _
lngBytesWritten, 0&)
Which should be this
Call apiWriteFile(hFile, abytData(0), lngBytesRead, _
lngBytesWritten, 0&)


--
Terry Kreft

"Hanspeter Leupin" <le***@csi.com> wrote in message
news:1l*****************************@40tude.net...
Hi NG,

I used the Internet Data Transfer Library of Dev Ashish found at
http://www.mvps.org/access/modules/mdl0037.htm to transfer text files from
a server with HTTPS in my old Ms Access 97 application.

'----snip----
Sub TestHTTP()
On Error GoTo ErrHandler
Dim objHTTP As InetTransferLib.HTTP
Const conTARGET = "https://ip.of.my.server/PathToMyFile/MyFile.csv"

Set objHTTP = New InetTransferLib.HTTP
With objHTTP
.HttpURL = conTARGET
.DestinationFile = "c:\MyFile.csv"
If .FileExists Then .OverwriteTarget = True
.ConnectToHTTPHost
.WriteHTTPDataToFile
End With
ExitHere:
On Error Resume Next
Set objHTTP = Nothing
Call SysCmd(acSysCmdRemoveMeter)
Exit Sub
ErrHandler:
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly,
Err.Source
Resume ExitHere
End Sub

This code was running fine for months - I did not changed anything but for
a couple of days I receive an error 6 - overflow message when
.WriteHTTPDataToFile is in progress.

The file size of MyFile.csv is about 100-250kb...

I tried to use the microsoft internet transfer control activex v6.0 but
with no success... ;-(

Any help or sample code is welcome

Regards

Hanspeter

Jan 6 '06 #2

P: n/a
Red
I love Dev's coding...

But, I would guess that the file being written is to big... but,
honestly, this is just a guess
~Red

Jan 7 '06 #3

P: n/a
Hi Terry,

Thanks for your replay.

On Fri, 6 Jan 2006 16:29:36 -0000, Terry Kreft wrote:
Call apiWriteFile(hFile, abytData(0), MAX_CHUNK, _
lngBytesWritten, 0&)
Which should be this
Call apiWriteFile(hFile, abytData(0), lngBytesRead, _
lngBytesWritten, 0&)

I replaced MAX_CHUNK with lngBytesRead... well the overflow error is gone -
but the download of the file doesn't work. The code loops for ever at the
line where I did the change. The progress bar doesn't move and the filesize
of my 20kb file stays at 0...

lngTotalBytesWritten = 0
'Read in MAX_CHUNK Chunk
Do
ReDim abytData(MAX_CHUNK)
lngRet = apiInetReadFile(hURL, abytData(0), MAX_CHUNK, lngBytesRead)
Call apiWriteFile(hFile, abytData(0), lngBytesRead, _
lngBytesWritten, 0&)
lngTotalBytesWritten = lngTotalBytesWritten + lngBytesWritten
Call SysCmd(acSysCmdUpdateMeter, CInt(lngTotalBytesWritten / mlngSize))
Loop Until lngRet <> 0 And lngBytesRead = 0
Any ideas or is there something missing ?

Hanspeter
Jan 7 '06 #4

P: n/a
On 6 Jan 2006 07:45:41 -0800, Red wrote:
I love Dev's coding...

But, I would guess that the file being written is to big... but,
honestly, this is just a guess
~Red


Hi Red,

well the code was fine till two weeks ago. The filesize was always in the
same range...

Is there no other code to transfer a file from https with a97?

Regards

Hanspeter
Jan 7 '06 #5

P: n/a
OK, there's something else going on.

Firstly don't worry about the file size staying at zero, IIRC the file size
doesn't get written until the download is finished.

I've tested this and it works fine.

The relevant piece of code I have in WriteHTTPDataToFile is :-
lngTotalBytesWritten = 0
'Read in MAX_CHUNK Chunk
Do
ReDim abytData(MAX_CHUNK)
lngRet = apiInetReadFile(hURL, _
abytData(0), _
MAX_CHUNK, _
lngBytesRead)
Call apiWriteFile(hFile, abytData(0), lngBytesRead, _
lngBytesWritten, 0&)
lngTotalBytesWritten = lngTotalBytesWritten + lngBytesWritten
Call SysCmd(acSysCmdUpdateMeter, CInt(lngTotalBytesWritten / mlngSize))
Loop Until lngRet <> 0 And lngBytesRead = 0
I'm call ing the routine as follows
Sub TestHTTP()
On Error GoTo ErrHandler
Dim objHTTP As InetTransferLib.HTTP
Const conTARGET = "http://www.mvps.org/access/acknowledge.htm"

Set objHTTP = New InetTransferLib.HTTP
With objHTTP
.HttpURL = conTARGET
.DestinationFile = "C:\test.htm"
If .FileExists Then .OverwriteTarget = True
.ConnectToHTTPHost
.WriteHTTPDataToFile
End With
ExitHere:
On Error Resume Next
Set objHTTP = Nothing
Call SysCmd(acSysCmdRemoveMeter)
Exit Sub
ErrHandler:
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly,
Err.Source
Resume ExitHere
End Sub

and this works. (the file created is 73.5 kb).

In the WriteHTTPDataToFile procedure try keeping a track of
lngBytesRead this should be at most MAX_CHUNK
lngBytesWritten this should be at most lngBytesRead
lngTotalBytesWritten this should be at most the size of your file in
bytes.

--
Terry Kreft

"Hanspeter Leupin" <le***@csi.com> wrote in message
news:rw****************************@40tude.net...
Hi Terry,

Thanks for your replay.

On Fri, 6 Jan 2006 16:29:36 -0000, Terry Kreft wrote:
Call apiWriteFile(hFile, abytData(0), MAX_CHUNK, _
lngBytesWritten, 0&)
Which should be this
Call apiWriteFile(hFile, abytData(0), lngBytesRead, _
lngBytesWritten, 0&)

I replaced MAX_CHUNK with lngBytesRead... well the overflow error is
gone -
but the download of the file doesn't work. The code loops for ever at the
line where I did the change. The progress bar doesn't move and the
filesize
of my 20kb file stays at 0...

lngTotalBytesWritten = 0
'Read in MAX_CHUNK Chunk
Do
ReDim abytData(MAX_CHUNK)
lngRet = apiInetReadFile(hURL, abytData(0), MAX_CHUNK, lngBytesRead)
Call apiWriteFile(hFile, abytData(0), lngBytesRead, _
lngBytesWritten, 0&)
lngTotalBytesWritten = lngTotalBytesWritten + lngBytesWritten
Call SysCmd(acSysCmdUpdateMeter, CInt(lngTotalBytesWritten / mlngSize))
Loop Until lngRet <> 0 And lngBytesRead = 0
Any ideas or is there something missing ?

Hanspeter

Jan 7 '06 #6

P: n/a
On Sat, 7 Jan 2006 12:17:29 -0000, Terry Kreft wrote:
OK, there's something else going on.

Firstly don't worry about the file size staying at zero, IIRC the file size
doesn't get written until the download is finished.

I've tested this and it works fine.

Const conTARGET = "http://www.mvps.org/access/acknowledge.htm"

and this works. (the file created is 73.5 kb).


Hi Terry,

I checked all the code and I tried the sample you did and it works fine
too! The download of http://www.mvps.org/access/acknowledge.htm worked...
but when I go back to my https page on the intranet the download breaks and
loops for ever... I reinstalled the certificates...

When ever IE was in the background open to the secure page - access97
successfully downloaded the files...

Well - we can keep on right click the files and store them localy... :-)

Reagrds

Hanspeter
Jan 7 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.