I guys,
I hope someone can help me with my recent problem.
I'm trying to download a Microsoft Access from the net in my Visual Basic 6 application. I'm using the INET control.
I've previously used this method to download a basic text document and it worked fine. So i wanted to download a MS Access document and thought i'd just modify the URL that it downloads from. But this didn't work. The Access document created is not a recognised Access document. Access won't open it neither will the Visual Basic 8 ADODC connect to the downloaded access document. both say it is not a recognised Access document.
Below is the Visual Baisc 6 code used when loading the form that is to download the file.
code:
ProgressBar1.Max = 281
Inet1.RequestTimeout = Timeout 'set timeout
Destination = <path to which access document will be save> 'set destination file
Inet1.Execute "<URL from which the access database will be downloaded>", "GET" 'Start the download of the specified file
This is the code that is executed when the status of the Inet control is changed:
code:
Static inProc As Boolean
If Not inProc Then 'only execute this procedure, if it is the first call (DoEvents in this sub may call this event frequently
inProc = True
Debug.Print Timer, State
Select Case State
Case icResponseReceived 'Received something
Dim vtData() As Byte 'Current Chunk
Do While Inet1.StillExecuting
DoEvents
Loop
Do
DoEvents
vtData = Inet1.GetChunk(256, 1)
If UBound(vtData) = -1 Then Exit Do 'exit loop, if no Chunk could received
ReDim Preserve file(SafeUBoundFile + UBound(vtData) + 1) 'enlarge file-array
CopyMemory file(UBound(file) - UBound(vtData)), vtData(0), UBound(vtData) + 1 'copy received Chunk to the file-array
If UBound(vtData) <> 255 Then Exit Do 'if the length of the chunk is not 255, then it must be the last chunk of the file
Dim tmp As Long
tmp = UBound(file) / 1024
If tmp > ProgressBar1.Max Then tmp = ProgressBar1.Max 'if KBs is higher then ProgressBar1.Max then truncated
ProgressBar1.Value = tmp 'update ProgressBar1
Loop
Inet1.Cancel
Open Destination For Binary As #1 'Write file-array to destination-file
Put #1, , file
'Close #1
Erase file 'free file-array
'inProc = False
FrmUpdate.Show
Unload Me
End Select
inProc = False
End If
Sorry if there is quite an obvious solution, but i haven't been programming for long and have tried many thing last night without success.
Thanks in advance
RileyM