0
我想操縱我的asp網絡mvc應用程序中的Excel 2010文件。OleDbException當調用OleDbConnection打開方法
這是代碼:
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\teste.xlsx;Extended Properties=\"Excel 12.0 Xml;HDR=YES\";";
OleDbConnection conexao = new OleDbConnection(connectionString);
conexao.Open();
Open()方法trows例外,我無法找出原因。
例外:
Erro: System.Data.OleDb.OleDbException (0x80004005): Failure creating file.
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at Gedi.Controllers.AdminController.File() in c:\Users\Guilherme\Documents\Visual Studio 2012\Projects\Gedi\Gedi\Controllers\AdminController.cs:line 62
是的文件在您訪問它的同時打開? –