Importing Excel into a Dataset

G

Guest

I've created a windows application with the follwoing code, and it works just fine:
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + System.AppDomain.CurrentDomain.BaseDirectory
+ "//XL//my.xls;" + "Extended Properties=Excel 8.0;";

OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM
[my$]", strConn);

DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet, "ExcelInfo");

When I try and run this under asp.net, I get the following error:

Unspecified error
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Unspecified error

I(ASP.NET) has full rights on the folder and the temp folder(http://support.microsoft.com/default.aspx?scid=kb;en-us;827190).

Is there something else I miss?
 
P

Paul Clement

¤ I've created a windows application with the follwoing code, and it works just fine:
¤ string strConn;
¤ strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
¤ "Data Source=" + System.AppDomain.CurrentDomain.BaseDirectory
¤ + "//XL//my.xls;" + "Extended Properties=Excel 8.0;";
¤
¤ OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM
¤ [my$]", strConn);
¤
¤ DataSet myDataSet = new DataSet();
¤ myCommand.Fill(myDataSet, "ExcelInfo");
¤
¤ When I try and run this under asp.net, I get the following error:
¤
¤ Unspecified error
¤ Description: An unhandled exception occurred during the execution of the
¤ current web request. Please review the stack trace for more information about
¤ the error and where it originated in the code.
¤
¤ Exception Details: System.Data.OleDb.OleDbException: Unspecified error
¤
¤ I(ASP.NET) has full rights on the folder and the temp folder(http://support.microsoft.com/default.aspx?scid=kb;en-us;827190).
¤
¤ Is there something else I miss?

Are you using impersonation? If so, what level of authentication are you using for your web app?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
G

Guest

We use Forms authentication. This is how I managed to resolve the issue:
I Ran a file monitor application to identify the file and related security
details. It said that ASP.NET did not have rights for the folder containing
the source code, which it had. I then, out of desparation, granted the IUSER
account rights to the folder, and it worked.

I wish I could understand the relationship between IUSER and ASP.NET user...

Thanks
 
P

Paul Clement

¤ We use Forms authentication. This is how I managed to resolve the issue:
¤ I Ran a file monitor application to identify the file and related security
¤ details. It said that ASP.NET did not have rights for the folder containing
¤ the source code, which it had. I then, out of desparation, granted the IUSER
¤ account rights to the folder, and it worked.
¤
¤ I wish I could understand the relationship between IUSER and ASP.NET user...
¤

IUSR_MACHINE is the configured anonymous account by default so your web application must be set up
for Anonymous access. This account has limited access with respect to resources.

Don't know whether your Forms based authentication is using LDAP or a database (such as SQL Server).


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
G

Guest

We're using a database. I still don't understand why IUSER required
permissions when ASPUser needs to perform the tasks.
Either way, it's resolved - Thanks
 
P

Paul Clement

¤ We're using a database. I still don't understand why IUSER required
¤ permissions when ASPUser needs to perform the tasks.
¤ Either way, it's resolved - Thanks
¤

Because IUSR_MACHINE is the identity of security context for the currently executing Win32 thread
(impersonated account) when using Anonymous authentication and <identity impersonate="true"/> in the
web.config file.

The ASPNET account is used when impersonation is turned off (<identity impersonate="false"/>) under
Anonymous authentication.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

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

Top