Problem with Large data

  • Thread starter Thread starter Husam
  • Start date Start date
H

Husam

Hi EveryBody:

I posted the following code two days ago when I face problem that my code
could not upload large data or to be prices more than 4 MB.

The code are :

Dim arrayImage As Byte() = FileUpload1.FileBytes
TextBox1.Text = FileUpload1.FileName
Dim nStr As String =
Me.TextBox1.Text.Substring(Me.TextBox1.Text.LastIndexOf("\") + 1)
Dim scon As SqlConnection = New
SqlConnection(ConfigurationManager.ConnectionStrings("Husam").ConnectionString)
Dim sql As String = "INSERT INTO MyTable(Name,Pic)" +
"VALUES(@Filename,@Picture)"
Dim cmd As New SqlCommand(sql, scon)
With cmd
.Parameters.Add(New SqlParameter("@Filename", SqlDbType.NVarChar,
50)).Value = nStr
.Parameters.Add(New SqlParameter("@Picture", SqlDbType.Image)).Value =
arrayImage
End With
scon.Open()
cmd.ExecuteNonQuery()
scon.Close()

Some body told me may be the problem are with line:

dim arrayimage() as byte=FileUpload1.FileBytes that put the whole file
content into the servermemory one and that may cause resourec problem.

And I may agree with him cause when ever i try use the above code with file
his size more than 4 Mb which is double my cache memory it stop uploading.

So Is there some one can help me in finding such way that can make me upload
large data either by spliting the file into pices and upload each pice alone
or some how?

any help or redirection will be completelly appreciated

regard's

Husam
 
In the Web.config file, override the value of maxRequestLength for the
application. For example, the following entry in Web.config allows files that
are less than or equal to 8 megabytes (MB) to be uploaded:
<httpRuntime maxRequestLength="8192" />
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: htp://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
 
Back
Top