Hello,
I am trying to upload an excel file into SQL server. The thing is I am stuck here
The line
gives pathname as C:\\FileName for which I get an exception that access is denied, and from this Why is access to the path denied?
I got to know that we can get these errors if the path is a directory. I know my path is wrong, but I am clueless as how to select the correct path for further processing.
My asp.net code is
When I referred this
and changed my code to
I got Could not find a part of the path exception.
I am trying to upload an excel file into SQL server. The thing is I am stuck here
C#:
string fileName = Path.Combine(@"C:\", FileUpload1.FileName);
FileUpload1.SaveAs(fileName);
String excelConnString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0\"", fileName);
The line
C#:
string fileName = Path.Combine(@"C:\", FileUpload1.FileName);
I got to know that we can get these errors if the path is a directory. I know my path is wrong, but I am clueless as how to select the correct path for further processing.
My asp.net code is
C#:
<asp:FileUpload ID="FileUpload1" runat="server" Width="368px" />
<p>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</p>
When I referred this
How To Import Excel Data In SQL Server Using ASP.NET
In this blog, we are going to learn how to import excel data into SQL database table using asp.net and display them into gridview jquery data table.
www.c-sharpcorner.com
C#:
string path = string.Concat(Server.MapPath("~/UploadFile/" + FileUpload1.FileName));
FileUpload1.SaveAs(path);
I got Could not find a part of the path exception.
C#:
+ $exception {"Could not find a part of the path 'C:\\Users\\AMEN\\source\\repos\\ExcelDatabase\\ExcelDatabase\\Files\\New Microsoft Excel Worksheet.xlsx'."} System.IO.DirectoryNotFoundException
Last edited: