473,287 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

OleDbConnection - cannot read Excel file

I have the following code in an asp.net page:

System.Data.OleDb.OleDbConnection cn = new
System.Data.OleDb.OleDbConnection();
cn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\myservername\ExcelTemp\Temp.xls;Extended Properties=Excel
8.0";
cn.Open();
cn.Close();

My IIS site (on localhost) is set to not allow anonymous users,
integrated security. My web.config has the following for impersonation:

<identity impersonate="true" userName="mydomain\workerprocess"
password="mypassword" />

When running this page, I get the helpful
System.Data.OleDb.OleDbException: Unspecified error. There is no record
in the security Event Log of MyServerName that access was attempted.

When I change web.config to:
<identity impersonate="true" />

I get: System.Data.OleDb.OleDbException: The Microsoft Jet database
engine cannot open the file '\\myservername\ExcelTemp\Temp.xls'. It is
already opened exclusively by another user, or you need permission to
view its data.

The security event log records four back-to-back login success audits
coming from my computer, but the user is ANONYMOUS LOGIN. For example:

Event Type: Success Audit
Event Source: Security
Event Category: Logon/Logoff
Event ID: 540
Date: 5/12/2006
Time: 1:43:31 PM
User: NT AUTHORITY\ANONYMOUS LOGON
Computer: MYSERVERNAME
Description:
Successful Network Logon:
User Name:
Domain:
Logon ID: (0x0,0xA685FE4E)
Logon Type: 3
Logon Process: NtLmSsp
Authentication Package: NTLM
Workstation Name: MYCOMPUTERNAME
Logon GUID: -
Caller User Name: -
Caller Domain: -
Caller Logon ID: -
Caller Process ID: -
Transited Services: -
Source Network Address: 10.0.100.100
Source Port: 0

Any ideas how to actually pass the identity being impersonated through
the OleDbConnection? This application reads several SQL Server
databases and everything is working just fine. But I need to read an
Excel file and can't get it to work. Any help would be greatly
appreciated.

May 12 '06 #1
2 5850
As with Access databases, a TEMP directory being used. The account under
which the web site is running will probably need full access to the "TEMP"
directory being used. It may be the one under "documents and
settings"\<machinename>\ASPNET\"Local Settings"\Temp....

--
Brad

"Software is like melted pudding..."

May 12 '06 #2
Brad, your suggestion worked. Thank you so much for your help.

Talk about misleading error messages....

Dave

May 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Zed | last post by:
I have a problem with .net writing to a remote server that I need to deploy on. The app works fine on my local machine. But when got access to the server I went to VS.NET and tried to create a...
3
by: Shreeram Natarajan | last post by:
Hello, Iam developing a sharepoint webpart which needs to read data from an excel file. Iam using OleDbconnection for reading data from excel. However using OleDbconnection object gives the...
5
by: CyberLotus | last post by:
Hi, I've created a web application and through this I want to import Excel data to database. Following is the code that I've written, ...
0
by: archana | last post by:
Hi all, I wrote one application to read excel files data into datatable. To get data of excel file into datatable i used oledbconnection. In connectonstring i set extended properties as excel...
0
by: m.trimble | last post by:
I've set up some visual basic .net code to read a spreadsheet. It works, but not all the time. Sometimes I get an error where the Microsoft Jet Engine could not access the spreadhsheet tab name,...
7
by: Miro | last post by:
I think i have found my problem following an example ive searched for on the net. I am using vb.net 2005 express. What I am looking for is a drag drop from the toolbar that is an...
0
by: Fendi Baba | last post by:
I created an ASP.net page which opens excel. This works fine in Office 2007. However, Excel 2003 runs in an error which states "cannot read output file". Hee is the VB code and below is the ASPX...
8
by: Fendi Baba | last post by:
I created an ASP.net page which opens excel. The data opens up correctly in MS office Excel 2007 but when we use a mahcine with MS Office 2003 we encountered a message, "Cannot read output file" Is...
5
by: abb | last post by:
On a Vista machine, the following code works using the ASP.NET Development Server, but fails in IIS7: book = excel.Workbooks.Open(tempfile, false, false, Missing.Value, Missing.Value,...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.