Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

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");
            try
            {
                OleDbCommand ocmd = new OleDbCommand("select * from [Bank Credits (A)]", oconn);
                oconn.Open();  
                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);                    
                }
            oconn.Close();
            }
            catch (DataException ee)
            {                
            }
            finally
            {                
            }        
        }
Avatar of Big Monty
Big Monty
Flag of United States of America image

double check the permissions on the folder where the excel file resides. Make sure the NETWORK SERVICE account has read/write privileges
Avatar of zimmer9

ASKER

U:\\Manual\\101-07-09-2013.xls
-----------------------------------------
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.
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial