• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4041
  • Last Modified:

How to resolve the error "Failure creating file" when importing an Excel 2003 file into a SQL Server 2005 table within an ASP.Net C# application using VS2010.

I am developing a C# ASP.Net 4.0 application using Excel 2003, VS2010 and SQL Server 2005.

My goal is to import an Excel 2003 file into a SQL Server 2005 table.

My company states that SQL Bulk Copy is not a company standard, so I need to find an alternate means of accomplishing my goal.

In the routine that follows, I get the error "Failure creating file"
on the statement "oconn.Open();  

System.Data.OleDb.OleDbException          Failure creating file

Do you know how I can resolve this error?

protected void Button3_Click(object sender, EventArgs e)
            OleDbConnection oconn = new OleDbConnection
                (@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=@U:\\Manual\\101-07-09-2013.xls;Extended Properties=Excel 8.0");
                OleDbCommand ocmd = new OleDbCommand("select * from [Bank Credits (A)]", oconn);
                OleDbDataReader odr = ocmd.ExecuteReader();
                string f1 = "";
                string f2 = "";
                string f3 = "";
                string f4 = "";
                string f5 = "";
                string f6 = "";
                while (odr.Read())
                    f1 = valid(odr, 0);
                    f2 = valid(odr, 1);
                    f3 = valid(odr, 2);
                    f4 = valid(odr, 3);
                    f5 = valid(odr, 4);
                    f6 = valid(odr, 5);                    
            catch (DataException ee)
  • 2
1 Solution
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
double check the permissions on the folder where the excel file resides. Make sure the NETWORK SERVICE account has read/write privileges
zimmer9Author Commented:
I can place files into folder U:\Manual, I can delete files in this folder and I can update files in this folder as well.
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
you may be able to yes, but does the account that IIS uses (which i believe is the NETWORK sERVICES account) have access?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now