.net - Opening XLSX File Via OleDb Works In WinForms But Not Always Via ASP.Net?
Apr 18, 2012
I've built a simple library to import data from XLS/XLSX files. The code runs perfectly in my WinForms app but occasionally throws exceptions when I run it from ASP.Net. The "occasional" part seems to based on file size. My test file is about 16,000 rows and 18 columns totaling about 4MB as an XLSX file. If I drop rows (down to about 12,000) it works or if I drop columns (down to about 12) it works or certain combinations of these (14,000x14, etc) it works. This leads me to believe that I'm possibly running into a memory constraint somewhere. Below is the distilled code that's not working:
Dim dsn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=""c: est.xlsx"";Extended Properties=Excel 12.0"
Using Con As New System.Data.OleDb.OleDbConnection(dsn)
Con.Open()'Exception thrown here
Con.Close()
End Using
The exception that I'm getting is:External table is not in the expected format Searches for this all talk about getting the DSN correct and since it works on the desktop I know I've got that right.My test machine is a Windows 7 64-bit with the Microsoft Access Database Engine 2010 Redistributable - 32 bit installed. (My machine has Office 2010 32 bit installed which is why I have the 32-bit ADE installed, it won't let you install 64-bit.) I've set my IIS app pool to allow 32-bit applications which I needed to get ADE to work in the first place. I'm running the v4 Framework and as far as I know my IIS settings are pretty much standard.Like I said, the code works every time when I run it through a WinForms app but occasionally fails through ASP.net on the same machine.
View 1 Replies
ADVERTISEMENT
Jul 14, 2010
My application generates XLSX files based on a users requirements.
After the XLSX file is generated the user is redirected to where the file is saved using Response.Redirect...
Response.Redirect("filename.xlsx")
When the user then opens the file... they recieve this message.
The file you are trying to open, 'filename.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?
As a temporary fix I've instructed my users to press "Yes" when they receive this message and the file opens perfectly fine.
Does anyone have any ideas why IE6 is trying to open an XLSX file as an XLS?
View 2 Replies
Jul 22, 2011
there is a problem I'm afraid there is no solution for, but I wish to ask anyway just in case someone knows.
My application downloads a third-party XLS file from the web. I cannot change its format so I have to teach my application to open it as it is.I'm using OleDb for opening, here's my
[Code]...
Now, when I get that table the headers are treated as data while the table title from the first row is considered a header. Is there a workaround or I just have to live with it?
View 5 Replies
Apr 19, 2012
Question: How do I programmatically determine which provider to use (Microsoft.Jet.OLEDB.4.0 vs Microsoft.ACE.OLEDB.12.0) when my app runs as a 32-bit process on a machine with Office x64 installed?
I'm developing a VB.net WinForms app in VS 2010 and targeting both x86 and x64.The app processes data from xls, xlsx, mdb and accdb files using System.Data.OleDb:Dim oConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=...")
The x64 version of the program works as expected. The x86 version works as expected on a system with Office x86.When I run the x86 version on a machine with Office 2010 x64, I get the following exception when trying to open a connection:
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.I believe this is because I'm running Office 2010 x64 so the x86 data access components are not installed.I can get it to work for Office 2003 files (*.mdb and *.xls) by changing the provider to Microsoft.Jet.OLEDB.4.0.
How do I figure out which provider to use when running as a 32-bit process on a machine with Office x64 installed?Ideally, I'd like a function:If ProviderIsAvailableFor("Microsoft.ACE.OLEDB.12.0") Then
Else If ProviderIsAvailableFor("Microsoft.JET.OLEDB.4.0") Then
View 8 Replies
Nov 25, 2009
I am trying to import a tab delimited file with ADO. If I convert my tabs to csv it works,but I would like to know why it does not work with tab.The Function is on the buttomhere is my test data:
Test1:
- Create a Text file with Headers: Test1, Test2, Test3
and rows:
[code].....
View 3 Replies
Apr 30, 2009
We have a form that hosts the WebBrowser control. That is the only control on the form.We pass the form the file path of a temporary PDF file and it does:WebBrowser1.Navigate(Me._PathToPdf)When the form is closing, it navigates away from the PDF file:
WebBrowser1.Hide()
WebBrowser1.Navigate("about:blank")
Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
[code].....
View 4 Replies
Mar 3, 2010
I am trying to FTP an .xlsx file. I have to code uploading the file, but it is uploading it in a zip folder. how I can fix this? Is it a setting I am seeting with my code, or is it a setting the the FTP page itself? The code shown below is the code i am using to FTP the file. It was posted to my other thread by bdbodger.
[Code]...
View 1 Replies
Jun 12, 2009
Is there a simple way in vb.net to load an excel file and read it? perhaps there is a way to load the file but have it not be visible to the user?
View 4 Replies
Jan 17, 2011
I am unable to import xlsx file in Asp .Net getting below error:-
Could not find installable ISAM.
I am using below code for importing xlsx file[cod]e...
View 5 Replies
Jul 5, 2010
How do i this?Import data from XLS,XLSX,CSV,XML excel file to .NET?
View 6 Replies
Dec 15, 2011
I have used the Process.start function to open an Excel file as shown in the code
Process.Start("report.xlsx") and it works perfectly well.
My question is can this function be used to open a particular worksheet called Report1 in the report.xlsx file. If so what would the code be.I have spent many hours trying to research this topic but without success.
View 5 Replies
Oct 1, 2009
I use the followoing code to import an xlsx file into an Access 2007 table. It works fine when I enter the exact file name.However, part of the file name is a date which will change every week.The file location does not change,just the date in the file name.[code]I've tried using a wildcard but I get a Run-time error 3011.Db engine could not find the object. Make sure the object exists.
View 1 Replies
May 19, 2011
I used Visual Studio 2005. It works well when testing, but when I publish it got error: Microsoft Office Excel cannot access the file 'D:OfficeStationaryV0.2ReportTMPReportItem.xlsx'. There are several possible reasons: - The file name or path does not exist. - The file is being used by another program. - The workbook you are trying to save has the same name as a currently open workbook.
my following code is:
Dim ExcelApp
As New Excel.Application
Dim xlWorkBook
As Excel.Workbook
[code]....
View 3 Replies
Jun 30, 2011
I would like to know the event order of form which is executed while opening form. I am showing my form using following code and the code in form_load event executes twice. Once when the form variables are initialised and second when form is displayed. I want it to execute once only. form showing code:
[Code]...
View 1 Replies
Oct 18, 2010
Just wondering if i might hit a snag in my program. Ive got 10+ users using the same files, via a Oledb to put info into an excel spreadsheet. If 2 or more people save there file at the same time will the program go into read only on one person. Normally one 3 will use the file at one time. I know Sql itself would be better to use. best way i can describe it, normally using excel if you manage to open the same file twice one opens as normal but the other opens as a Read only file, will the same thing happen if im using Oledb connections?
View 2 Replies
Aug 25, 2009
I have been able to export data from a query to the xlsx file..howerver those fields which are currency in my sql server 2005 table are currency are showing up in the spreadsheet as text. The column mappings are correct when I look at it in connection manager.
Also Is there also a way to create a new worksheet each time the export is run or does the file have to be already named?
View 2 Replies
Aug 23, 2009
I am using OLEDB to import data from a CSV file into my database. The code works great as long as the file has a .CSV extension. My problem is that it fails if the file has no extension which is the actual case in my files.
View 7 Replies
Jun 22, 2010
I have always used Excel.interop before but I thought oledb would be simpler because, for this application, I only have to read the data which it can't seem to do. It accesses the file alright because I can't open the file while I am at a breakpoint. It attempts to read the file because oExcelReader.fieldcount = 14 which is correct. oExcelReader.hasrows = true which is not correct. The line where I use getstring(1) errors out and says there is no data for this row/column.
[Code]...
View 1 Replies
Aug 13, 2009
I have some excel file, where I have to programatically delete all hidden columns.The problem if that, when I receive these files, the cells are mainly formulas, and as I delete some columns I get some "#REF#" problems.
I thought a bit about the problem an decided to create a function that loops throught all cells and replace the value by its own value, before deleting the columns, via OLEDB:
dt.Rows(row)(col) = dt.Rows(row)(col).ToString I don't know if this works. So I followed an update example I found in google, but it doesn't work:
Dim conexao_Excel As String = "Provider=Microsoft.Jet.OleDb.4.0;data source=" & fileName & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1;"""
cn = New OleDbConnection(conexao_Excel)
cn.Open()
da = New OleDbDataAdapter("SELECT * FROM [" & sheetname & "]", cn)
da.Fill(dt)
[Code]...
"Update requires a valid UpdateCommand when passed DataRow collection with modified rows." I image this is pretty basic, but I have already lost so much time on this issues...
View 1 Replies
Feb 18, 2011
I'm writing an application in VB.net 2010, using Visual Studio 2010 Pro on a Win 7 Computer. The test code works for me correctly. However when I ziped the project folder and sent it to a friend (who is using Visual Basic 2010 on an Win XP Computer), it did not work correctly.
While runing the program in debug, we found a section of that code reads an XML file to construct an object provides a different results on the two computers. I'm not sure why the same code would parse parts of same XML differently. Most of the XML parsed correctly on both computer, just a couple of sections provides the incorrect result on the XP Computer using VB 2010 Express.
Sample of XML that reads differently:
<players>
<min>2</min>
<max>2</max>
[Code]....
View 4 Replies
Nov 15, 2011
Using OleDbDataReader, how does one determine if the Excel workbook is empty? BTW, OleDbDataReader.HasRows seems to always be True even for a workbook with no data.
View 1 Replies
Aug 15, 2011
My program reads a 3rd party .txt file using OleDb and reads the file into a datatable. It's overall working fine except a user will occasionally have a problem reading a file. At this point.
Line that gets hung up
Try
Dim comm1 As New OleDbCommand("SELECT * FROM " & safeFileName & " Where " & Status & " = '" & StatusClosed & "'", con)
Dim dasold As New OleDbDataAdapter(comm1)
dasold.Fill(dtsold)
AddColsold()
[Code] .....
It can not retrieve a date for one of the fields, then gives error and does not get dates for each records after the one it gets hung up on but the date is in the file. If I open the file in excel and play with the column sizing, for instance just autoformat column width then it read the date and will work fine. I have looked at the file in notepad and cant see anything wrong in particular on the record it gets hung up on. I have no control over the .txt file since it comes form a 3rd party.
View 16 Replies
Feb 15, 2012
I have a program that can save user's input into a text file and load it back, but whenever I try to open the file and exit without selecting the file I get an error.(if i select the file and open it i don't get any errors).
This is the code that handles text file loading:
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
OpenFileDialog1.InitialDirectory = "C:"
OpenFileDialog1.Filter = "Text Files ONLY (*.txt) | *.txt"
OpenFileDialog1.ShowDialog()
[CODE]...
The error is :"FileNotFoundException was unhandled. Could not find file at xxx". also I would like to know how to make it so that the initial file name for file saving is today's date. I do not get any errors when I try to save the file.
View 7 Replies
May 22, 2012
I need to open an excel file from vb.net and then search it for specific data. I then need to take those data and insert them into text boxes on a form that i have created. This is all controlled by a button click. I already have some code that will open a file dialog box and let me navigate to the correct file, but I am having trouble with the search portion. I have tried the Find function but I am not sure of the proper syntax. I am using Visual Studio 2008 and Excel 2003.
[Code]...
View 7 Replies
Sep 2, 2009
Im running VB.Net 2005.Inside of the program I use the line ystem.Diagnostics.Process.Start("program_) to open multiple programs. For all but one of them this works perfectly. This erros when I try to run a batch file using. System.Diagnostics.Process.Start("C:xx.bat") the batch file opens but then throughs a number of unreconizable java errors follow.
[Code]...
View 2 Replies
Feb 9, 2011
Need explanation on basics of the file format conversion in VB.net. I absolutely don't know anything about the file format conversion, so a starter here.
View 2 Replies
Jan 20, 2009
First of all I am not a really experienced programmer, sorry for that. I try to do my best.So far my application is succeeding: it can create a directory for itself download a file from the internet, rename it to the matching unique id for the user, replace the file and backup the old one.
THe problem I now have that the file to download is 22mb, with .rar it's only 3mb. Zo I tried to zip it (also worked) but now I need my application to decromress it. After a lot of search I found this method from MSDN:
[Code]...
View 1 Replies
May 12, 2011
I use the following code to write to a Foxpro DBF. The SQL table I am reading from has 9500 rows. When I loop through the following code, I get an error after about 940 rows. There is nothing wrong with the SQL data. The message I get is 'Variable Q940P65 is not found'
Public g_OLEDB_ConnectionString As String = "Provider=vfpoledb;Data Source=N:;Collating Sequence=machine;"
dim strSQL as string = "INSERT INTO STATEUSR(DATEFIELD, STATECODE, MINAMOUNT) VALUES(?,?,?)"
[Code]....
View 4 Replies
Feb 15, 2012
I have this program that uses OLEDB connection to import excel file to data table then use it in other functions.Now I have this question: What are the possible limitations of OLEDB when it reads the Excel file. The File is on xls format, and I want to know if there is such limitations(for example: It has limitation in reading value on a cell).
View 6 Replies
Dec 4, 2009
I've done successful updates to Access databases with VB.net code using OleDb lines, with some sample code as follows:
Dim GRDatabase As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=|DataDirectory|OWVGuestRegister.mdb")
Dim GRCommand As OleDbCommand
GRDatabase.Open()
[Code] .....
How to update Excel and Text files the same way?
View 4 Replies