在VB2010中打开受密码保护的Access 2010数据库 [英] Open password-protected Access 2010 database in VB2010

查看:374
本文介绍了在VB2010中打开受密码保护的Access 2010数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从VB2010应用程序中打开一个受密码保护的Access 2010数据库.无需密码即可正常进行连接,因此我知道所有其他参数均已正确设置.但是,当我将密码添加到连接字符串时,出现一个错误,多步OLE DB操作生成了错误.请检查每个OLE DB状态值(如果可用).未完成任何工作."我知道密码是正确的,因为当我直接在Access中打开数据库时,将其复制并粘贴到密码对话框中时,密码才可以使用.

I need to open a password-protected Access 2010 database from a VB2010 application. The connection works fine without a password, so I know I have all other parameters set correctly. But when I add the password to the connection string I get an error, "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." I know the password is correct because it works when I copy and paste it into the password dialog when opening the database directly in Access.

这是我使用的代码.错误发生在adapter.fill命令:

Here is the code I use. The error occurs at the adapter.fill command:

    Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" +
            "Data Source=" + Application.StartupPath + "\MyData.accdb;Jet OLEDB:Database Password=MyPassword;")

    Dim command As OleDbCommand = New OleDbCommand()
    command.Connection = conn
    command.CommandText = "SELECT * FROM MyTable"

    Dim table As DataTable = New DataTable()

    Dim adapter As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(command)

    adapter.Fill(table)

推荐答案

我认为这是Access 2010中的错误:

I think it's a bug in Access 2010 : https://www.connectionstrings.com/access-2010/

行情:

使用数据库密码这是您使用时的连接字符串 具有使用密码保护的Access 2007-2013数据库 Access中的设置数据库密码"功能.

With database password This is the connection string to use when you have an Access 2007 - 2013 database protected with a password using the "Set Database Password" function in Access.

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
Jet OLEDB:Database Password=MyDbPassword; 

一些关于密码长度超过14个字符的问题的报告.还有一些字符 可能会造成麻烦.如果遇到问题,请尝试更改密码 换成一个短而又普通的字符.

Some reports of problems with password longer than 14 characters. Also that some characters might cause trouble. If you are having problems, try change password to a short one with normal characters.

注意!报告说 使用Access 2010-2013默认加密方案加密的数据库 不适用于此连接字符串.在访问中;尝试选项和 选择2007加密方法代替.那应该使它工作.我们的确是 不知道任何其他解决方案.如果有其他解决方案,请联系 可用!

Note! Reports say that a database encrypted using Access 2010 - 2013 default encryption scheme does not work with this connection string. In Access; try options and choose 2007 encryption method instead. That should make it work. We do not know of any other solution. Please get in touch if other solutions is available!

另外,作为提示,您不需要说

Also, as a tip, you don't need to say

Dim conn As OleDbConnection = New OleDbConnection("Connection String")

您可以做

Dim conn As New OleDbConnection("Connection String)

这篇关于在VB2010中打开受密码保护的Access 2010数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆