Solved

Uploading Large xlsx file

Posted on 2011-09-08
2
235 Views
Last Modified: 2012-05-12
Hi,

I have several pages where user upload excel files for importing records into a database.

I detect the format and open the connection string appropriately like this.

If FileUpload1.HasFile Then
                    strExt = Right(FileUpload1.FileName, (Len(FileUpload1.FileName) - InStrRev(FileUpload1.FileName, ".")) + 1)
                    If strExt = ".xls" Or strExt = ".xlsx" Then
                        Dim strLocalPath As String
                        strLocalPath = DLookUp("ParamValue", "tblSysParam", "ParamName = 'TempFileDir'")
                        txtPath.Text = strLocalPath
                        strFileName = ExactTimeString() & strExt
                        txtFile.Text = strFileName
                        FileUpload1.SaveAs(strLocalPath & strFileName)
                        If strExt = ".xls" Then
                            strC = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & strLocalPath & strFileName & "';Extended Properties=Excel 8.0"
                        ElseIf strExt = ".xlsx" Then
                            strC = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & strLocalPath & strFileName & "';Extended Properties=Excel 12.0"
                        End If
                        txtConn.Text = strC
                    Else
                        DisplayAlert("File of type " & strExt & " not permitted only .xls or .xlsx maybe uploaded.", Me.Page)
                        CleanUp()
                        Reset()
                        Exit Try
                    End If
                Else
                    DisplayAlert("No sample information detected.\n\nIf you believe this to be an error please contact your system administrator.", Me.Page)
                    CleanUp()
                    Reset()
                    Exit Try
                End If
                myConnection.ConnectionString = strC
                myConnection.Open()

Open in new window


I know my code can handle 2007 format as I have sucessfully uploaded some. However, when I upload a large file (30MB) I get the external table is not in correct format error.

What is really weird is if I upload the same file in excel 2003 format it works. So I know it is not the maxupload size that is the problem. I had read that the permissions of the temporaryinternbet files folder could be an issue but then why would it work with 2003?

If I remove a large portion of the data from the 2007 version of the file (leaving the number of columns in tact) the connection works so I must be hitting a size threshold but I can't figure out what setting I need to change.

I am totally stumped here. Can anyone help?

Ell
0
Comment
Question by:PrisonBroken
2 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 total points
Comment Utility
Create a custom HTTP module to track the progress of file upload and see where it stucks. Please go through below articles.

http://dotnetslackers.com/Community/blogs/haissam/archive/2008/09/12/upload-large-files-in-asp-net-using-httpmodule.aspx

http://aspnetresources.com/articles/dark_side_of_file_uploads

If the problem with file size then increase the file upload size: http://weblogs.asp.net/skoganti/archive/2004/02/22/78124.aspx
0
 
LVL 3

Author Comment

by:PrisonBroken
Comment Utility
Sorry EaswaranP,

Been on holiday will try this and get back to you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now