【问题标题】:aspnetdb.mdf and Microsoft.ACE.OLEDB.12.0aspnetdb.mdf 和 Microsoft.ACE.OLEDB.12.0
【发布时间】:2011-03-30 03:00:19
【问题描述】:

我正在尝试在仅安装了 Microsoft.ACE.OLEDB.12.0 作为数据库引擎并且需要连接到标准 aspnetdb 的 Windows 机器(XP SP3、Vista、7)上运行我的 asp.net 应用程序。 mdf 用户数据库。

有人知道在这种情况下可以使用与 mdf 文件一起使用的连接字符串吗?我使用了这样的连接字符串,但还没有成功:

connectionString = "provider=Microsoft.ACE.OLEDB.12.0;Data Source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true";

谢谢

【问题讨论】:

  • 我看不出那个连接字符串有什么问题。也许如果你发布了你得到的错误,你会得到答案。

标签: asp.net-mvc-2 oledb sql-server-express aspnetdb


【解决方案1】:

试试这样的:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\aspnetdb.accdb;Persist Security Info=False;

更多连接字符串,请转至http://www.connectionstrings.com/access-2007

编辑:无法使用 OleDB 连接到 Sql Server 数据库。改为安装 SQL Server (Express)。

【讨论】:

  • 感谢 ZippyV,但当我尝试打开连接时出现以下错误:无法识别的数据库格式 'C:\Users\Mehrdad\Documents\Visual Studio 2010\Projects\radsoft\radsoft\App_Data\ ASPNETDB.MDF'。 C#中的代码是:String connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|aspnetdb.mdf;Persist Security Info=False;"; OleDbConnection 连接 = 新 OleDbConnection(connectionString); Connection.Open();
  • 我怀疑使用此 OLEDB 提供程序连接到 mdf 数据库的可能性!
  • 我以为您使用的是 Access 数据库。现在我看到一个 mdf 文件来自 sql server。无法使用 OLEDB 提供程序连接到 sql server 数据库。只需安装 SQL Server Express 即可解决您的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-24
  • 2011-02-23
  • 1970-01-01
  • 2011-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多