melli111
asked on
ASP.NET error "Failure creating file."
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.O LEDB.4.0;D ata Source=//server/EstimateWB S/template .xls;Exten ded Properties=""Excel 8.0;HDR=YES;""";
using (OleDbConnection connection = new OleDbConnection(connection string))
{
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=passwor d";
using (SqlBulkCopy copy = new SqlBulkCopy(SQLconnections tring))
{
copy.DestinationTableName = "WBS";
copy.WriteToServer(datarea der);
}
}
}
string connectionstring = @"Provider=Microsoft.Jet.O
using (OleDbConnection connection = new OleDbConnection(connection
{
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=passwor
using (SqlBulkCopy copy = new SqlBulkCopy(SQLconnections
{
copy.DestinationTableName = "WBS";
copy.WriteToServer(datarea
}
}
}
ASKER
Yes, teh file itself has rights. Could it possibly be that the fodler on the network does not have sufficient priviliges?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
string connectionstring = @"Provider=Microsoft.Jet.O
And this file exists, and whatever user your program/website is running as has rights to the file?