【问题标题】:Web.config - Target database from parent-folderWeb.config - 来自父文件夹的目标数据库
【发布时间】:2017-11-06 14:48:45
【问题描述】:

我有一个数据库在我的应用程序文件夹内的App_Data 文件夹中。我想将数据库移动到根/父文件夹(在我的应用程序的父文件夹中)并且仍然能够访问它。

-(root)The_database_where_I_want_to_use.db
- - ApplicationFolder
- - - App_Data/MyDatabase.db

这是我当前在 Web.config 中的连接字符串:

    <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; 
     Data Source = |DataDirectory|\MyDatabase.mdb" providerName="System.Data.OleDb" />

如何在根文件夹中定位“The_database_where_I_want_to_use.db”?

【问题讨论】:

  • 你试过只留下Data Source = The_database_where_I_want_to_use.mdb吗?

标签: asp.net webforms web-config


【解决方案1】:

你可以配置`Data Source = ./MyDatabase.mdb"'

点是 Web 应用程序的根

  <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; 
 Data Source = ./MyDatabase.mdb" providerName="System.Data.OleDb" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-25
    相关资源
    最近更新 更多