以前连接access总是连接没有加密的数据库,今天在做东西时候突然想到连下加密的access数据库,结果调试了半天也没成功!后来上http://www.connectionstrings.com(经常去看看,上面包罗了目前所有数据库的连接字符串)这个网站看了下终于明白了!呵呵!!
下面是代码:
![]()
Code
try
{
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\test.mdb;Jet OLEDB:Database Password=19871024;";
OleDbConnection conn = new OleDbConnection(constr);
conn.Open();
Response.Write("连接成功!");
conn.Close();
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
}
因为在调试,所以用try、catch来捕获异常,因为程序崩溃了,关来关去太麻烦!呵呵!