DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   Downloading an mdb file using INET (http://www.daniweb.com/forums/thread167569.html)

No Pain No Gain Jan 10th, 2009 4:53 pm
Downloading an mdb file using INET
 
The code below downloads the test.mdb file but when I try to open it MS Access says it is in an unrecognised format.

Is it not possible to use Inet for downloading an Access database?

Dim strURL As String
Dim bData() As Byte ' Data variable
Dim intFile As Integer ' FreeFile variable

strURL = "http://www.asite/test.mdb"
intFile = FreeFile()
bData() = Inet1.OpenURL(strURL, icByteArray)
Open App.Path & "\test.mdb" For Binary Access Write As #intFile
Put #intFile, , bData()
Close #intFile

Comatose Jan 10th, 2009 5:06 pm
Re: Downloading an mdb file using INET
 
Are you sure that the database is in the same format (ie, did you make the database in Access 2007, and are opening it in 2003?)

No Pain No Gain Jan 10th, 2009 5:09 pm
Re: Downloading an mdb file using INET
 
Good idea but made in 2000 and trying to open it in 2000

Comatose Jan 10th, 2009 5:14 pm
Re: Downloading an mdb file using INET
 
Mkay, have you tried opening the original (open it with wordpad or notepad, unless it's huge) and then opening the one downloaded through VB, and see if they are the same size and the same basic byte structure etc? And there is no DB on http://www.asite.com for me to check it myself ;)

No Pain No Gain Jan 10th, 2009 5:18 pm
Re: Downloading an mdb file using INET
 
Your previous post made me wonder if the database I was using was corrupt. So I just grabbed another, checked it would open OK, posted it to a website, downloaded it OK, but Access doesn't recognise it.

Comatose Jan 10th, 2009 5:24 pm
Re: Downloading an mdb file using INET
 
weird...are the file sizes the same and all that?

No Pain No Gain Jan 10th, 2009 5:26 pm
Re: Downloading an mdb file using INET
 
Just tried open both in Notepad.

Original is gobblydegook

Dowloaded one is bigger and a text file about a missing file

Comatose Jan 10th, 2009 5:28 pm
Re: Downloading an mdb file using INET
 
the gobblydegook is fine, that means it's in access format... if the other opens some kind of weird text, then obviously access won't read it.... now the question is, what is this text about missing files?

No Pain No Gain Jan 10th, 2009 5:36 pm
Re: Downloading an mdb file using INET
 
Just posted a simple text file 1.txt with one word in. Changed the app.path to c:\.1.txt

The text file downloads fine and I can open it and see the word. If I alter the two .txt to .mdb and download the database I can still download it but part of what I find in Notepad is this:

"The type of page you have requested is not served because it has been explicitly forbidden.  The extension '.mdb' may be incorrect.   Please review the URL below and make sure that it is spelled correctly."

It seems to be something to do with Access.

I have to go now will let you know tomorrow if I sort it.

Thanks for your help.

Comatose Jan 10th, 2009 5:38 pm
Re: Downloading an mdb file using INET
 
The web server is forbidding the web browser from accessing .mdb files... makes sense for security reasons. On the server, rename the .mdb file to something like "mydatabase.zip" and when you have downloaded the file, have vb rename it to something like "mydatabase.mdb"


All times are GMT -4. The time now is 10:37 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC