简体   繁体   English

使用Delphi 7和MS Access 2010测试连接错误

[英]Test connection error with delphi 7 and MS access 2010

I have an Ado connection in my form and use Access 2010 ( accdb database ) 64 bit system 我的表单中有一个Ado连接,并使用Access 2010(accdb数据库)64位系统

I have a password set in access 2010 for my DB 我在Access 2010中为数据库设置了密码

I am using Ado connection string to connect Delphi 7 and the 2010 Access database. 我正在使用Ado连接字符串来连接Delphi 7和2010 Access数据库。

when I try to set connection an error occurs that says "test connection failed because of an error in initializing provider. cannot open database." 当我尝试设置连接时,发生错误,提示“由于初始化提供程序时出错,导致测试连接失败。无法打开数据库。” It may not be a database that your application recognizes, or the file may be corrupt. 它可能不是您的应用程序可以识别的数据库,或者文件可能已损坏。

However, when I create another database without a password, the ado connection string works after testing connection. 但是,当我创建另一个没有密码的数据库时,ado连接字符串在测试连接后会起作用。

I have also installed AccessDatabaseEngine but it still does not work. 我还安装了AccessDatabaseEngine,但仍然无法正常工作。 In addition, The Ado is working with the password on my other computer with 32bit system but fails on 64bit system. 此外,Ado正在另一台装有32位系统的计算机上使用密码,但在64位系统上却无法使用。 What is the solution and why is this happening? 解决方案是什么,为什么会这样?

It seems like the ADO ConnectionString Builder does not create a Connection String that works with password protected mdb's... at least I could not get it working :-) 似乎ADO ConnectionString Builder无法创建与受密码保护的mdb一起使用的连接字符串...至少我无法使其正常工作:-)

When using the ADO ConnectionString Builder I got the error, "Cannot start your application. The workgroup information file is missing or opened exclusively by another user." 使用ADO ConnectionString Builder时,出现错误“无法启动您的应用程序。工作组信息文件丢失或由另一个用户独占打开。” This was the malfunctioning connection string: 这是发生故障的连接字符串:

Provider=Microsoft.Jet.OLEDB.4.0;Password=MyPwd;Data Source=C:\...\MyDB.mdb;Persist Security Info=True

I solved it by writing code that assigned the connection string advised in this SO solution . 我通过编写分配此SO解决方案中建议的连接字符串的代码解决了该问题 Here's my code: 这是我的代码:

ADOConnection1.LoginPrompt := false;
ADOConnection1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\...\MyDB.mdb;Jet OLEDB:Database Password=MyPwd;';
ADOConnection1.Connected := true;

Note: I used Delphi XE3, 32bit app on Win 7 64bit. 注意:我在Win 7 64bit上使用了32位应用程序Delphi XE3。

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

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