如何连接到访问2007年用C# [英] how to connect to access 2007 with c#
问题描述
哎,
I是新的连接到数据库,出于某种原因,每次我用那些以下行我的程序崩溃时间:
hey, i am new at connecting to dataBases and for some reason each time i use those following lines my program collapse:
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;DataSource=|DataDirectory|\Company.accdb"
OleDbConnection con = new OleDbConnection(connectionString);
我debug文件夹里,我得到Company.accdb访问文件
编辑:
I我得到'Microsoft.Ace.OLEDB12.0'提供者未在本地机器上注册的任何想法如何解决呢?
在此先感谢您的帮助。
inside my debug folder i got Company.accdb access file edit: i am getting 'Microsoft.Ace.OLEDB12.0' provider is not registered on the local machine any idea how to solve it? thanks in advance for your help
推荐答案
两件事情 -
- 此连接字符串依靠ACE OLEDB提供程序(通常随Office 2007 - 你的机器需要有这样的供应商)
-
连接字符串请求数据字典。您可能需要使用下面的形式:
- This connection string rely on ACE OLEDB provider (typically comes with Office 2007 - your machine need to have this provider)
Connection string is requesting data dictionary. You probably need to use below form:
提供商= Microsoft.ACE.OLEDB.12.0;数据源= C:\myFolder\myAccess2007file.accdb;坚持安全信息= FALSE;
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;
有关密码保护的文件,形式是提供程序= Microsoft.ACE。 OLEDB.12.0;数据源= C:\myFolder\myAccess2007file.accdb;喷射OLEDB:数据库密码= MyDbPassword;
For password protected files, form would be Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Jet OLEDB:Database Password=MyDbPassword;
我会(ODBC也许),而不是也建议尝试不同的供应商。有关Access 2007中各种连接字符串,请参阅 http://www.connectionstrings.com/access-2007
I will also suggest trying different Provider (ODBC perhaps) instead. For various connection strings for Access 2007, refer http://www.connectionstrings.com/access-2007
这篇关于如何连接到访问2007年用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!