Hi to everybody.
I am using C#.net for convert Excel file to DataGrid for Client Request.
When i using the page to convert the excel to datagrid at localhost it worked properly, but it will not work when i'm publish the site.
The error is
System.Data.Ole Db.OleDbExcepti on: 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.
The Code is
I am using C#.net for convert Excel file to DataGrid for Client Request.
When i using the page to convert the excel to datagrid at localhost it worked properly, but it will not work when i'm publish the site.
The error is
System.Data.Ole Db.OleDbExcepti on: 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.
The Code is
Code:
protected void Upload_Click(object sender, EventArgs e)
{
try
{
strFileName = fleupForQuotation.PostedFile.FileName;
if (strFileName.Trim() != "")
{
string folderpath = "F://Upload//";
string attachedFile = fleupForQuotation.PostedFile.FileName;
if (Request.Browser.Browser == "IE")
{
fleupForQuotation.SaveAs(folderpath + fleupForQuotation.FileName);
strFileName = folderpath + fleupForQuotation.FileName;
}
else
{
fleupForQuotation.SaveAs(folderpath + attachedFile);
strFileName = folderpath + attachedFile;
}
hdnFileName.Value = strFileName;
}
else
{
}
}
catch (Exception ex)
{
SRCMError.ErrorLog(ex.ToString());
SRCMError.ExceptionToEventLog(ex);
}
string ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=" + strFileName + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(ConnectionString);
conn.Open();
try
{
OleDbDataAdapter oda = new OleDbDataAdapter("select * from [Sheet1$]", conn);
DataSet ds = new DataSet();
oda.Fill(ds, "Details");
grdExceltoGrid.DataSource = ds;
grdExceltoGrid.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
conn.Close();
}
}