简体   繁体   English

C#Microsoft Acces数据库连接错误

[英]C# Microsoft Acces Database Connection Error

My loggining form is stopping on connection.Open(); 我的登录表单停止在connection.Open(); , I'm getting an error: System.Data.OleDb.OleDbException: unrecognized database format . ,出现错误: System.Data.OleDb.OleDbException: unrecognized database format Code with connection operations: 具有连接操作的代码:

    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();

What to do with that? 怎么办呢? Thank you very mutch for your help. 非常感谢您的帮助。

I don't think you need the @ before your string. 我认为您不需要在字符串前使用@。 Also I think you should do like this : 我也认为你应该这样做:

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

Here is the source I used to answer you : https://www.codeproject.com/Articles/823854/How-to-connect-SQL-Database-to-your-Csharp-program 这是我用来回答您的消息源: https : //www.codeproject.com/Articles/823854/How-to-connect-SQL-Database-to-your-Csharp-program

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM