Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Unspecified Error" filling DataSet with data from Excel Worksheet 1

Status
Not open for further replies.

mavalon

Programmer
Apr 18, 2003
125
0
0
US
The following code works in one project but not another:

Dim fl As String = Server.MapPath("parser.xls")
If File.Exists(fl) Then
File.Delete(fl)
End If
fileUpload.PostedFile.SaveAs(fl)

Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & fl & ";Extended Properties=Excel 8.0;"
Dim myCommand As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn)
Dim dt As DataTable = New DataTable
myCommand.Fill(dt)

NOTE: The error I get is "Unspecified Error" (really helpful). It occurs on the last line above. The file IS being saved, it has "Sheet1", and "Sheet1" has data.

Thanks in advance.
 
Try adding a Try/Catch around the code and then have a look at the Exception error messages.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I actually did, and the error was "Unspecified Error". Anyway, I got it to work.

I have always had permissions problems in .NET. This is quite odd:

Even though I granted Full Control Permission to the IUSR_SERVERNAME user, and was therefore able to upload the file, I wasn't able to read from it. Once I granted Read rights to the EVERYONE user, I was able to read from it.

Very strange, quirky stuff, but it works nevertheless.

Thanks for your reply.
 
By default, ASP.NET runs under the ASPNET user account so you may want to check permissions for that user (if you are running Windows 2003 also check the Network Service account).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
You're absolutely right! (My bad.) I removed EVERYONE, added ASPNET, and it works.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top