I suspect the issue is rooted in the call to Server.MapPath(fileupFile.FileName)
. The FileName
property is a convenience property to indicate the original file name of the content being uploaded to the server. It doesn't necessarily indicate the location or the name of the file when (and if) you save it on the server.
It would seem that you still need to receive the file on the server side and save it to disk. There are several ways to do so. The SaveAs()
method is perhaps the easiest, but you also have the FileBytes
and FileContent
properties which give you access to the uploaded file as a byte array or a stream, respectively.
If you first save the document to your hard drive and then construct your connection string, I believe that will resolve the issue.
Here is a simple example of saving an uploaded file. Assume that the "~/Documents" folder has granted the IIS worker process write permissions (or that you use impersonation and your authenticated user has write permissions):
var targetfilepath = Path.Combine(Server.MapPath(~/Documents), fileupFile.FileName);
fileupFile.SaveAs(targetfilepath);
var connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + targetfilepath + ";Extended Properties=Excel 12.0";
// ...
Good luck.
By the way, and you may already know, there is an excellent reference on Excel 2007 connection string properties at connectionstrings.com: http://connectionstrings.com/excel-2007