473,379 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

How to upload the excel file to server?

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.OleDb.OleDbException: 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

Expand|Select|Wrap|Line Numbers
  1. protected void Upload_Click(object sender, EventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 strFileName = fleupForQuotation.PostedFile.FileName;
  6.                 if (strFileName.Trim() != "")
  7.                 {
  8.                     string folderpath = "F://Upload//";
  9.                     string attachedFile = fleupForQuotation.PostedFile.FileName;
  10.                     if (Request.Browser.Browser == "IE")
  11.                     {
  12.                         fleupForQuotation.SaveAs(folderpath + fleupForQuotation.FileName);
  13.                         strFileName = folderpath + fleupForQuotation.FileName;
  14.                     }
  15.                     else
  16.                     {
  17.                         fleupForQuotation.SaveAs(folderpath + attachedFile);
  18.                         strFileName = folderpath + attachedFile;
  19.                     }
  20.                     hdnFileName.Value = strFileName;
  21.  
  22.  
  23.                 }
  24.                 else
  25.                 {
  26.                 }
  27.             }
  28.             catch (Exception ex)
  29.             {
  30.                 SRCMError.ErrorLog(ex.ToString());
  31.                 SRCMError.ExceptionToEventLog(ex);
  32.             }
  33.  
  34.  
  35.  
  36.             string ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=" + strFileName + ";" + "Extended Properties=Excel 8.0;";
  37.  
  38.             OleDbConnection conn = new OleDbConnection(ConnectionString);
  39.  
  40.             conn.Open();
  41.  
  42.             try
  43.             {
  44.  
  45.  
  46.                 OleDbDataAdapter oda = new OleDbDataAdapter("select * from [Sheet1$]", conn);
  47.  
  48.                 DataSet ds = new DataSet();
  49.  
  50.                 oda.Fill(ds, "Details");
  51.  
  52.                 grdExceltoGrid.DataSource = ds;
  53.  
  54.                 grdExceltoGrid.DataBind();
  55.  
  56.             }
  57.  
  58.             catch (Exception ex)
  59.             {
  60.  
  61.                 Response.Write(ex.Message);
  62.  
  63.             }
  64.  
  65.             finally
  66.             {
  67.  
  68.                 conn.Close();
  69.  
  70.             }
  71.  
  72.         }
Jun 12 '10 #1
0 1183

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: LBT | last post by:
Hi experts, With response.contenttype = "application/vnd.ms-excel", I can easily export my data to Excel which is embeded and shown within a browser. If I'm going to save the Excel file...
0
by: Thomas.LeBlanc | last post by:
We would like to upload Excel files to SQL Server database server that is exposed through IIS. We are using the http calls from a .Net C# Windows Forms application. This is a prototype, that is...
2
by: Sreedhar Vankayala | last post by:
Hi, I joined a project where we need to import data from a excel file into sql server via the asp.net. After doing a long research found that #1. Upload Excel file to the server #2. Load or...
0
by: powerranger | last post by:
I wrote an asp.net application where I can upload an Excel file to the server and get the data from it to display on my datagrid. The program compile without error. The file loaded on the server...
1
by: vic pahilan | last post by:
hi, pls need help. I need to upload excel field to sql server field. the user will choose excel file then i will show the fields inside that excel file then copy it into sql server field. I...
3
by: c676228 | last post by:
Hi everyone, I will develop a program to enroll a group of people on-line. Since we don't have number limitation for the people in the group. I am wondering if there is any company allow people...
5
by: vimal.424 | last post by:
Hi......all.... can any body tell me how can we upload excel file & send the excel file data in database. I;m not able to do........please help me...... thanks in advance
0
by: minhtran | last post by:
Hi all Please, I am a new ASP.NET, I upload an Excel File in the database, but I have an error as "Invalid Signature" . Please, anyone has a knowledge how to solve this problem and share with me , I...
0
by: minhtran | last post by:
Hi all I have a problem when I upload the Excel file 2007 (file.xlsx) via ASP.NET (VB.NET, C#), but it has no problem to upload the Excel file 2003 (file.xls). Please, anyone can help me to solve...
5
by: priyammaheshwari | last post by:
Hi all, I have a MS Access database in which requests made by people is stored,but a coulmn for cost is left empty which is suppose to be populated by the administrator.Now the administrator wants...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.