Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 July 29th, 2004, 02:23 PM
Authorized User
 
Join Date: Jun 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with downloading files from access databas

Hi gurus,

 I am facing this problem. I am uploading all my files (from the client to server), in an access database. I am also displaying the files , everything was fine until people started uploading files bigger than 4 mb. I cannot display any file bigger than 4mb.
 It seems that there is a need of changing the "AspBufferinLimit" variable in the metabase.xml file on the server. now my server is on godaddy.com, i cannot make any changes.
Is there any other way to change the buffer size.
i tried to set "Response.Buffer=False", but still problem persists.
i get the following error:


<p>Response object error 'ASP 0251 : 80004005'
<p>
Response Buffer Limit Exceeded
<p>
/admin/file.asp, line 33
<p>
Execution of the ASP page caused the Response Buffer to exceed its configured limit.



BTW, the code i am suing to dislay the file is:

<% Response.Buffer = false
if session("UserID")="" or session("UserType")<> "Administrator" then
response.redirect("/index.htm")
end if
%>
<%
    ' -- file.asp --
    ' Retrieves binary files from the database



    ' ID of the file to retrieve
    Dim ID
        ID = Request("ID")

    If Len(ID) < 1 Then
        ID = 7
    End If

    ' Connection String
    Dim connStr
        connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("\db/NIRO.mdb")

    ' Recordset Object
    Dim rs
        Set rs = Server.CreateObject("ADODB.Recordset")

        ' opening connection
        rs.Open "select [Attachment],[AttachmentType],[contenttype] from RequestAttachment where RequestID = " & request("RequestID") & " and attachmentnum=" & ID, connStr, 2, 4

        If Not rs.EOF Then
            Response.ContentType = rs("contenttype")
            Response.BinaryWrite rs("Attachment")



        End If


        rs.Close
        Set rs = Nothing
%>


Thanks in advance
iniro

__________________
------------------------
http://www.indrajal.com
 
Old August 4th, 2004, 03:34 PM
Authorized User
 
Join Date: Jun 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for anyone who tried.
I figured it out.
In my previous code the line
 Response.BinaryWrite rs("Attachment")
downloads the whole attachment or datafield at one time. so if it is greater than 4mb it gives a problem.
Now, i am breaking down any field greater than 4mb in to chunks of 1mb and then flushing the buffer.
the new code is below:
Code:
Dim rs
        Set rs = Server.CreateObject("ADODB.Recordset")

        ' opening connection
        rs.Open "select [Attachment],[AttachmentType],[contenttype],filename, [filesize] from RequestAttachment where RequestID = " & request("RequestID") & " and attachmentnum=" & ID, connStr, 2, 4

            if Not rs.EOF then

                if rs("FileSize")< 4194304 then
                    Response.ContentType = rs("contenttype")
                    Response.BinaryWrite rs("Attachment")
                else

                    dim aSize , disp
                    aSize=rs("Attachment").ActualSize
                    Response.ContentType = rs("contenttype")
                    while not aSize < 0 

                        disp=rs("attachment").getchunk(1048576)

                        response.binarywrite disp            
                        response.Flush()
                        response.Clear()
                        aSize=aSize-1048576            
                    wend
                end if
            End If


        rs.Close
        Set rs = Nothing


it works great for any size of file stored in database.
hope it helps to other ppl.

 
Old September 1st, 2004, 02:43 PM
Registered User
 
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnproasp/html/binarydata.asp

ID = Request.QueryString("ID")
BlockSize = 4096
Response.ContentType = "image/JPEG"
strQuery = "SELECT * FROM Blob WHERE Blob_ID = " & ID
Set oRS = oConn.Execute(strQuery) 'oConn is a Session level object
oRS.MoveFirst
Set Field = oRS("Blob")
FileLength = Field.ActualSize
NumBlocks = FileLength \ BlockSize
LeftOver = FileLength Mod BlockSize
Response.BinaryWrite Field.GetChunk(LeftOver)
For intLoop = 1 To NumBlocks
  Response.BinaryWrite Field.GetChunk(BlockSize)
Next
oRS.Close

 
Old September 1st, 2004, 08:45 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default


Hi,

  I want to know the same thing. Now, i got this thru this post.

Thank you both.

 
Old September 1st, 2004, 11:16 PM
Authorized User
 
Join Date: Aug 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sinapra Send a message via MSN to sinapra Send a message via Yahoo to sinapra
Default

thanks, that helped me too

regards

sinapra
 
Old September 7th, 2004, 03:53 AM
Authorized User
 
Join Date: Jun 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No probs sinpra and rajni. I was stuck with this problem and couldnt find any help online.
i am glad it was useful to you.






Similar Threads
Thread Thread Starter Forum Replies Last Post
storing and retrieving pdf files in an sql databas jake ASP.NET 1.0 and 1.1 Basics 3 December 14th, 2006 03:09 PM
Downloading files via a browser gfrank1157 ASP.NET 2.0 Basics 3 June 14th, 2006 04:13 PM
Problem downloading sensitive files mat41 Classic ASP Professional 1 May 4th, 2006 08:45 PM
Protect Files from downloading asif_sharif ASP.NET 1.0 and 1.1 Professional 6 January 11th, 2006 01:59 AM
downloading files serge Classic ASP Professional 4 September 8th, 2003 10:36 AM





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