English 中文(简体)
C# 加密的. accdb 连接
原标题:C# enctypted .accdb connection

我最近更新了我的数据库,从.mdb(MS Access 2003)更新为.accdb(MS Access 2010)。

更新后,我还更新了我的供应商,从 Microsoft.Jet.OLEDB.4.0 Microsoft.ACE.OLEDB.12.0

当我在没有密码的情况下使用.accdb 文件时, 连接工作正常, 但一旦我选择

用密码加密

当我试图打开连接时, 我收到以下错误 。

Cannot open database . It may not be a database that your application recognizes, or the file may be corrupt.

已使用的连接字符串 :

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\App\Main\bin\Debug\db.xxx;
Jet OLEDB:Database Password=MyPass;

注意: 我对我的. accdb 文件使用自定义扩展名, 这个扩展名用于. mdb 文件, 没有问题, 我想这不应该是一个问题( 测试 ) 。

最佳回答

我看不出你的连接字符串有什么问题,但我还是会从VBA试试看,看看这项努力是否揭示了问题。

这个来自 Accdb 2007 访问, 不论我用“ accdb” 或“xx” 文件扩展名命名 db 文件。 在我密码上不需要单引号; 不管我是否包含单引号, 密码都成功 。

Public Sub OleDbToEncryptedAccdb()
     Const cstrDb As String = "encryptd.accdb"  
    Const cstrDb As String = "encryptd.xxx"
    Const cstrFolder As String = "C:shareAccess"
    Const cstrPassWord As String = "letmein"
    Dim cn As Object
    Dim strConnect As String

    strConnect = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
        cstrFolder & Chr(92) & cstrDb & _
        ";Jet OLEDB:Database Password= " & cstrPassWord & " ;"
    Debug.Print strConnect
    Set cn = CreateObject("ADODB.Connection")
    cn.ConnectionString = strConnect
    cn.Open
    cn.Close
    Set cn = Nothing
End Sub

Edit :显然2010年存取提供了比以前存取版本更强的加密方法。2010年存取时打开了 db.xxx ,请检查ACE的哪个版本被使用为 Provider

? CurrentProject.Connection.Provider

如果它回复了类似 Microsoft.ACE.OLEDB.1.40. 的回复, 请在您的 C# 连接字符串中使用该选项 。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签