Last post Jun 25, 2012 02:50 AM by shabirhakim1
Jun 20, 2012 11:15 PM|Shamini26|LINK
I am trying to upload an excel sheet to sql server 2008 database.
While I try to upload file in the lical machine it works fine. After publishing it on the server and tried in the same server I got the following error:
While I try it in a remote machine the following error appears
ERROR: Access to the path 'C:\inetpub\wwwroot\Project\Contractor\Details.xls' is denied.
Can anybody please help me to debug from this erros.
This is my code: (asp.net and vb)
If FileUpload1.HasFile Then
Dim path As String = Server.MapPath("~/")
FileUpload1.SaveAs(path + FileUpload1.FileName)
Message2.Text = "File name: " & _
FileUpload1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpload1.PostedFile.ContentLength & " kb<br>" & _
"Content type: " & _
Catch ex As Exception
Message2.Text = "ERROR: " & ex.Message.ToString()
Message2.Text = "You have not specified a file."
'Declare Variables - Edit these based on your particular situation
Dim sSQLTable As String = "ImportTable"
Dim sExcelFileName As String = FileUpload1.PostedFile.FileName
Dim sWorkbook As String = "[Data$]"
'Create our connection strings
Dim sExcelConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(sExcelFileName) & ";Extended Properties=""Excel 8.0;HDR=YES;"""
Thanks in advance
Jun 21, 2012 02:15 AM|shabirhakim1|LINK
There is no issue with code just you need to find out from the IIS SERVER application pool for the website what is the identity it is running under (by default this is Application Pool Identity) and grant that the correct permissions.
Jun 21, 2012 08:43 PM|Decker Dong - MSFT|LINK
The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data.
Please make sure that your OleDbConnection or something has been Closed after you want to use another connection to connect to the database table……
And you should make sure that no other threads or apps are sharing the same app……
Restart your IIS and have a try with that，
Reguards and Thanks！
Jun 25, 2012 02:42 AM|Shamini26|LINK
Thank you shabirhakim1 for your reply.
Could you please let me know how to grant permissions to application pool identity and what are the permissions to be granted.
Jun 25, 2012 02:50 AM|shabirhakim1|LINK
Make sure that folder has write permissions also Apart To see other options that you can choose for your application pool identity, go to IIS Manager, Application Pools and right-click on the pool you want to configure, select Advanced Settings and Identity
in the dialog that opens. You can choose one of the built-in accounts for your application pool identity