vb.net 连接到具有数据库密码的 Access 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2049017/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connecting to an Access database that has a database password
提问by user225269
I've password protected an mdb file but then I cannot access it on vb.net. I don't know the correct code for defining the password. this is my current code, I know its wrong, but I don't also know the correct code:
我用密码保护了一个 mdb 文件,但后来我无法在 vb.net 上访问它。我不知道定义密码的正确代码。这是我当前的代码,我知道它是错误的,但我也不知道正确的代码:
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\search.mdb;pwd=nit"
回答by Steve Strickland
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Jet OLEDB:Database Password=MyDbPassword;"
is the correct format for your connection string.
是您的连接字符串的正确格式。
Check out http://www.connectionstrings.com/access-2007for more info.
回答by Wade73
I believe the connection string should look like this:
我相信连接字符串应该是这样的:
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:Database Password=MyDbPassword;"
Here is a link to a site which can help with connection string questions ConnectionStrings.ComHTH
这是一个可以帮助解决连接字符串问题的站点的链接ConnectionStrings.ComHTH