【问题标题】:C# Microsoft Acces Database Connection ErrorC# Microsoft Access 数据库连接错误
【发布时间】:2018-07-11 15:15:34
【问题描述】:

我的登录表单在 connection.Open(); 上停止,出现错误:System.Data.OleDb.OleDbException: unrecognized database format。带有连接操作的代码:

    OleDbConnection connection = new OleDbConnection();
    connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=W:\Data Base\Test.accdb;
Persist Security Info=False;";
    connection.Open();
    connection.Close();

怎么办?非常感谢您的帮助。

【问题讨论】:

  • 我想说accdb 文件格式不支持存在问题。

标签: c# database winforms oledb oledbconnection


【解决方案1】:

我认为你不需要在你的字符串之前加上@。 我也认为你应该这样做:

connection.ConnectionString = "Server=[server_name];Database=[database_name];Trusted_Connection=true";

这里是我用来回答你的来源:https://www.codeproject.com/Articles/823854/How-to-connect-SQL-Database-to-your-Csharp-program

【讨论】:

  • 我使用的是 OleDb,而不是 SQL Server,只是 MS Access
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-09-29
  • 1970-01-01
  • 2022-11-22
  • 2010-12-08
  • 1970-01-01
  • 2015-05-17
相关资源
最近更新 更多