Download Large data

H

Husam

Hi EveryBody:

I have the following code to download the data from my web application:

the code is:

Dim rawan As New List(Of String) ' for File Name
Dim rawan1 As New List(Of Byte()) ' for the data for each file
Dim objconn As SqlConnection = New
SqlConnection(ConfigurationManager.ConnectionStrings("Husam").ConnectionString)
Try
Dim objcom As SqlCommand
objcom = New SqlCommand("SELECT * FROM " + s, objconn)
objconn.Open()
Dim myread As SqlDataReader =
objcom.ExecuteReader(CommandBehavior.CloseConnection)
If myread.HasRows = True Then
While myread.Read()
rawan.Add(myread.GetValue(0))
rawan1.Add(myread.GetValue(1))
End While
Me.Response.BinaryWrite(rawan1(ListBox1.SelectedIndex))
Dim husam As String = rawan(ListBox1.SelectedIndex)
Response.AddHeader("Content-Disposition", "attachment; filename=" + husam)
End If
myread.Close()
objconn.Close()
Catch ex As Exception
Throw New Exception(ex.Message)
objconn.Close()
End Try

when I run this code to download small data like 4MB it works well,but when
I use it to download large data for example let's say 345 MB there is an
error occure that tell me the SystemOutOfMemory.

I read about something called MaxResponseHeadersSize Property which I
though it Like MaxRequestLength that I used before to make my application
upload large data more than 4mb, but the requirments for this proprtey is
windows 2003 or 2000 server side and windows xp clinte side.

So is there some body can help me in this problem?

any help or redirection will be apprediated

regard's

Husam
 
B

bruce barker

the default is build the response in memory, then send it. with your large
size, you runout of memeory (see machine.config for max memory size))

if your response is this large you want to send it right away. turn page
bufferring off. you will need to write the headers before content. use
flush() to flush the buffers. also you will need to up the page timeout
(default 1 minute), because a download of this size may takes minutes (about
1 hour over dsl).

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top