ADO/RDO
64位windows系统如何使用64位的ADO连接Accesss accdb数据库(ACE.OLEDB)
2017-05-28 06:41:07

有关VBA如何同时兼容32位与64位Access Excel 等Office

可以参考这篇文章:

Access Excel VBA程序同时兼容32位和64位的解决办法

http://www.access-cn.com/info/3665-cn.html

由于Access以前的格式是mdb, 从Access2007之后数据库格式改为 accdb

而如果希望在64位的windows系统中使用ADO连接Access数据库,或在Access以ADO代码的方式连接数据库

就必须安装 Microsoft Access 2010 数据库引擎可再发行程序包

可以在这里下载

Office Data Providers (AccessDatabaseEngine_x64.exe) 

http://www.microsoft.com/zh-cn/download/details.aspx?id=13255

安装后可以使用  

"Provider=Microsoft.ACE.OLEDB.12.0

微软的相关说明:

  • If you are the user of an application, consult your application documentation for details on how to use the appropriate driver.

  • If you are an application developer using OLEDB, set the Provider argument of the ConnectionString property to “Microsoft.ACE.OLEDB.12.0” If you are connecting to Microsoft Office Excel data, add the appropriate Extended Properties of the OLEDB connection string based on the Excel file type: File Type (extension)                                             Extended Properties---------------------------------------------------------------------------------------------Excel 97-2003 Workbook (.xls)                                  "Excel 8.0"Excel 2007-2010 Workbook (.xlsx)                             "Excel 12.0 Xml"Excel 2007-2010 Macro-enabled workbook (.xlsm)      "Excel 12.0 Macro"Excel 2007-2010 Non-XML binary workbook (.xlsb)      "Excel 12.0"

  • If you are an application developer using ODBC to connect to Microsoft Office Access data, set the Connection String to “Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=path to mdb/accdb file”

  • If you are an application developer using ODBC to connect to Microsoft Office Excel data, set the Connection String to “Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=path to xls/xlsx/xlsm/xlsb file”

附相关的连接字符串大全:

Excel 97-2003

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myOldExcelFile.xls;Extended Properties="Excel 8.0;HDR=YES";

Excel 2007-2013

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES";

Access 97-2003

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.mdb;Persist Security Info=False;

Access 2007

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;Persist Security Info=False;

DBF / FoxPro

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\folder;Extended Properties=dBASE IV;User ID=Admin;

住:

"HDR=Yes;"声名第一行的数据为域名,并非数据。 

"HDR=No;"第一行为数据。