?
Solved

ASP.NET error "Failure creating file."

Posted on 2011-02-16
3
Medium Priority
?
805 Views
Last Modified: 2012-05-11
I am using a program that that opens an Excel file and reads it and writes the contents to a SQL Server database.  The code I am using is as follows:


string connectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=//server/EstimateWBS/template.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
        using (OleDbConnection connection = new OleDbConnection(connectionstring))
        {
            OleDbCommand command = new OleDbCommand("SELECT * FROM [Sheet1$]", connection);
            connection.Open();    <----------------------- ERROR OCCURS
            using (DbDataReader datareader = command.ExecuteReader())
            {
                string SQLconnectionstring = "Data Source=datasource;Initial Catalog=table;Persist Security Info=True;User ID=userid;Password=password";
                using (SqlBulkCopy copy = new SqlBulkCopy(SQLconnectionstring))
                {
                    copy.DestinationTableName = "WBS";
                    copy.WriteToServer(datareader);
                }
            }
        }
0
Comment
Question by:melli111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34911013
Maybe it's just a typo, but those should be back-slashes in the file's path in the connection string (I assume you're on Windows).

string connectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\server\EstimateWBS\template.xls;Extended Properties=""Excel 8.0;HDR=YES;""";

And this file exists, and whatever user your program/website is running as has rights to the file?
0
 
LVL 15

Author Comment

by:melli111
ID: 34911560
Yes, teh file itself has rights.  Could it possibly be that the fodler on the network does not have sufficient priviliges?
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 2000 total points
ID: 34911714
Yes, as well as the share.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question