Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

download ms access file to client computer

Status
Not open for further replies.

AzizKamal

Programmer
Apr 6, 2010
122
PK
In my asp page, there is a Download button. Clicking this button downloads data from oracle to an MS-Access (.mdb) file. This file is located on server at c:\Inetpub\ and filename is NewHRISDATA.mdb.

When the data insertion in MS-Access file is done, datatoxs.asp page is displayed showing the success message and a Download File Button. Clicking Download File Button was showing File Download dialog box with Open, Save and Cancel buttons and users were saving MS-Access file to their computers using this button.

Database server, Application Server and client computer were on workgroup earlier but now active directory services are installed and now all three are on the same domain. With this change (removing computers from workgroup and joining domain), Download File Button is no more working. When the user clicks Download File button, an error displays as follows:

There is a problem with the page you are trying to reach and it cannot be displayed. HTTP 500 – Internal Server Error.

This error occurs on startDownload.asp page, which has the following code:

Code:
Response.Buffer = True
Dim strFilePath, strFileSize, strFileName

Const adTypeBinary = 1

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fileObject = fso.GetFile(Request.Form("File"))

strFilePath = Request.Form("File")
strFileSize = fileObject.size
strFileName = fileObject.Name
Response.Clear

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

strFileType = lcase(Right(strFileName, 4))
    
    Select Case strFileType
        Case ".asf"
            ContentType = "video/x-ms-asf"
        Case ".avi"
            ContentType = "video/avi"
        Case ".doc"
            ContentType = "application/msword"
        Case ".zip"
            ContentType = "application/zip"
        Case ".xls"
            ContentType = "application/vnd.ms-excel"
        Case ".gif"
            ContentType = "image/gif"
        Case ".jpg", "jpeg"
            ContentType = "image/jpeg"
        Case ".wav"
            ContentType = "audio/wav"
        Case ".mp3"
            ContentType = "audio/mpeg3"
        Case ".mpg", "mpeg"
            ContentType = "video/mpeg"
        Case ".rtf"
            ContentType = "application/rtf"
		Case ".htm", "html"
            ContentType = "text/html"
		Case ".asp"
            ContentType = "text/asp"
		Case ".mdb"
			ContentType = "application/msaccess"			            
        Case Else
            ContentType = "application/octet-stream"
    End Select
	
	
	Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
	Response.AddHeader "Content-Length", strFileSize
	Response.Charset = "UTF-8"
	Response.ContentType = ContentType
	
	Response.BinaryWrite objStream.Read
	Response.Flush

objStream.Close
Set objStream = Nothing

We also have Excel .xls files in c:\Inetpub\ and startDownload.asp is working OK for Excel Files. But it is showing error for ms access files.
 
New Access files have a suffix of .accdb

Don't know if that would be the problem but it might be something to note.

 
If you just want the users to be able to save the MDB file, you can try the contenttype "application/x-unknown"

And with that 500 error, it sounds like the client browser has "Show Friendly HTTP Error Messages" turned on... You can turn this off in IE under Tools > Internet Options > Advanced
 
Thanks BigRed1212 and guitarzan.

I tried the contenttype "application/x-unknown":

Code:
Case ".mdb"
 ContentType = "application/x-unknown"

but it generated the same error.

I unchecked Show friendly HTTP error messages on my computer and accessed the application through my computer as client computer. Now clicking the Download File button shows the File Download dialog box, but upon clicking Save, it stuck at Getting File Information. Filename and file size are not shown. After a while, a message displayed:

Internet Explorer cannot download startDownload.asp from server. The connection with the server was reset.

I copied the whole application files on my computer and made my computer both application server and client computer. In that case, the above code worked perfectly with no error messages?? and I downloaded the ms access file successfully.

On my computer, MS Access 2002 and MS Access 2007 are installed. When I defined tablenames and fieldnames in this .mdb file, I used MS Access 2002 at that time.

I asked our Network Administrator, and on application server, only MS Access 2007 is installed. Does this make any difference??
 
I have not been able to resolve the issue as yet.

But I found more details during my testing.

It seems that the issue is not particularly related to ms-access but related to size of the file. I tried to download another ms-access mdb file from the application server. Application server was another computer and my computer was client. File size was 1.47 MB and it downloaded successfully. Then I tried to download another ms-access mdb file whose size was 6.06 MB and this file could not be downloaded.

Is there a way to increase the file download size??

On application server, windows server 2003 service pack 1 is installed. IIS version is 6.0.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top