【问题标题】:System.Data.OleDb.OleDbException: Not a valid file nameSystem.Data.OleDb.OleDbException:不是有效的文件名
【发布时间】:2014-01-22 15:00:45
【问题描述】:

如果您访问:

http://www.acoin.co.il/

您将看到错误/消息:

来源错误:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

堆栈跟踪:

[OleDbException (0x80004005): Not a valid file name.]
   System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +351
   System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +86
   System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +31
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +76
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
   System.Data.OleDb.OleDbConnection.Open() +43
   Acoin.index.Page_Load(Object sender, EventArgs e) +145
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

这是我的代码;

string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=http://www.acoin.co.il/database1.mdb;Persist Security Info=False";
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();

【问题讨论】:

  • 这种连接字符串中不能使用http协议。文件必须在本地或 LAN 上。由于它似乎与代码位置相同,请尝试 Data Source=database1.mdb 或使用相对于代码位置的位置

标签: c# asp.net database oledb


【解决方案1】:

似乎该 URL 已损坏(与 OleDB 连接无关):

http://www.acoin.co.il/database1.mdb:

404 - 找不到文件或目录。
您正在寻找的资源 可能已被删除、名称已更改或暂时 不可用。

但是,如果您可以使用 HTTP URL 作为数据库文件位置,我会感到惊讶

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 2013-11-02
    • 1970-01-01
    • 1970-01-01
    • 2022-08-14
    • 1970-01-01
    相关资源
    最近更新 更多