最近,有PDF.NET用户问我怎么在64位 系统 下无法访问Access 数据库 的问题,我第一反应是我怎么没有遇到呢?今天一看自己的VS和Office都是32位版本的,所以在VS里面调试访问Access是没有问题的,但是直接 使用 编译好的.NET程序访问Access,就出问题了,报:
最近,有PDF.NET用户问我怎么在64位系统下无法访问Access数据库的问题,我第一反应是我怎么没有遇到呢?今天一看自己的VS和Office都是32位版本的,所以在VS里面调试访问Access是没有问题的,但是直接使用编译好的.NET程序访问Access,就出问题了,报:
未在本地计算机上注册“Microsoft.Jet.Oledb.4.0”提供程序。
于是,又在公司的电脑上(Win7 64位)做了实验,发现跟家里面的Win8.1 64位 问题一样,上网搜索了一下,大部分都建议将.NET程序编译的时候,目标平台设定为 x86 ,我试了下,果然成功。
但是,如果你的.NET程序是别人编译好的,且在64位系统上运行,要访问Access数据库,怎么办呢?
首先想到,看能否通过应用程序配置文件,将.NET程序配置成运行在 32位 系统下,找了很久资料,无果,放弃。
再想想,是不是跟自己的Office是32位有关呢?
关键问题不在于是Access 2010还是Access 2013而已,不必钻牛角尖,何不求其次,安装一个Access 2007/2010的Database Engine不就行了。
解决办法:
① 下载安装Microsoft Access Database Engine 2010 Redistributable(28MB),共有32bit(下载)和64bit(下载)两个版本,具体要安装哪个要看你的Office程序是32bit的还是64bit的,比如:我的PC是64bit的Win8 Pro,但是我Office的程序是32bit的,所以我应当安装AccessDatabaseEngine.exe(32bit);
② 打开你的.NET应用程序配置文件(应用程序名.config,Web应用程序为 Web.config),设置数据库连接字符串的Provide Microsoft.ACE.OLEDB.12.0,例如标准连接字符串为:"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Data.accdb;Persist Security Info=False;"
再次运行程序,OK,数据库连接成功,一切正常。
注意:64位系统下一定要修改提供程序为 Microsoft.ACE.OLEDB.12.0,而此时的文件名,可以是 早期的 mdb文件,也可以是新的 accdb 文件。
如果你虽然是64位系统,但是你的Office 是32位的,所以你只能安装32位的ACE驱动,因此你的.NET应用程序也只能发布成32位的,如果编译成anycpu版本,还是无法访问ACE。
(PS:如果你发布成x86格式的目标平台,并且不想使用accdb格式的Access数据库文件,那么就不必安装上面的32位ACE驱动了,省得折腾:-《)
此问题受影响的 PDF.NET 开发框架相关程序:
1,SimpleAccessWinForm 程序,下载地址 , PDF.Net_V4.6 WinForm 数据表单实例
example, 526K, uploaded Mar 27, 2013 - 809 downloads
运行该程序后,请修改 SimpleAccessWinForm.config 文件的内容,如果是第一次运行,程序会自动创建该文件 并自动创建数据库文件,文件内容比如:
<span></span><span>xml version="1.0" encoding="utf-8"</span><span>?></span> <span><span>configuration</span><span>></span> <span><span>connectionStrings</span><span>></span> <span><span>add </span><span>name</span><span>="AccessConn"</span><span> connectionString</span><span>="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=TEST.mdb"</span><span> providerName</span><span>="Access"</span> <span>/></span> <span></span><span>connectionStrings</span><span>></span> <span></span><span>configuration</span><span>></span></span></span></span>
2,PDF.NET集成开发工具,下载地址: 安装程序
application, 1576K, uploaded May 25, 2011 - 1943 downloads
下载后,请找到运行目录下的 子目录 Config ,然后打开配置文件 DataConnectionCfg.xml ,找到相关的配置节:
<span></span><span>xml version="1.0" encoding="utf-8" </span><span>?></span> <span><span>DataConnections</span><span>></span> <span><span>Group </span><span>Name</span><span>="默认分组"</span><span>></span> <span><span>Connection </span><span>DbType</span><span>="SQLServer"</span><span> Name</span><span>="default"</span><span> ConnectionString</span><span>="Data Source=.;Integrated Security=True"</span> <span>/></span> <span><span>Connection </span><span>DbType</span><span>="SQLServer"</span><span> Name</span><span>=".\SQLEXPRESS"</span><span> ConnectionString</span><span>="Data Source=.\SQLEXPRESS;Integrated Security=True"</span> <span>/></span> <span><span>Connection </span><span>DbType</span><span>="SQLServerCe"</span><span> Name</span><span>="SQLCE"</span><span> ConnectionString</span><span>="Data Source=E:\DAC\LocalDB.sdf;Password=sasa;Persist Security Info=True"</span> <span>/></span> <span></span><span>Group</span><span>></span> <span><span>Group </span><span>Name</span><span>="XX二期"</span><span>></span> <span><span>Connection </span><span>DbType</span><span>="SQLite"</span><span> Name</span><span>="SQLite"</span><span> ConnectionString</span><span>="Data Source=E:\jjzd.db"</span><span> Provider</span><span>="PWMIS.DataProvider.Data.SQLite,DataAccess"</span><span>/></span> <span><span>Connection </span><span>DbType</span><span>="SQLServer"</span><span> Name</span><span>="192.168.50.1"</span><span> ConnectionString</span><span>="server=192.168.50.5;uid=sa;pwd=sasa"</span><span> Provider</span><span>=""</span><span>/></span> <span></span><span>Group</span><span>></span> <span><span>Group </span><span>Name</span><span>="分组2"</span><span>></span> <span><span>Connection </span><span>DbType</span><span>="Access"</span><span> Name</span><span>="default"</span><span> ConnectionString</span><span>="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=TEST.mdb"</span><span> Provider</span><span>="Access"</span><span>/></span> <span><span>Connection </span><span>DbType</span><span>="SQLServer"</span><span> Name</span><span>="50.25"</span><span> ConnectionString</span><span>="server=192.168.50.25;uid=sa;pwd=sasa"</span><span> Provider</span><span>=""</span><span>/></span> <span></span><span>Group</span><span>></span> <span></span><span>DataConnections</span><span>></span></span></span></span></span></span></span></span></span></span></span></span>
经过这样的配置以后,就可以直接打开集成开发工具了,如下图:
总结:
64位系统下.NET访问Access 数据库,最彻底的方法是安装64位的Access数据访问驱动安装程序 并使用新的Access提供程序 Microsoft.ACE.OLEDB.12.0

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The steps to build a MySQL database include: 1. Create a database and table, 2. Insert data, and 3. Conduct queries. First, use the CREATEDATABASE and CREATETABLE statements to create the database and table, then use the INSERTINTO statement to insert the data, and finally use the SELECT statement to query the data.

MySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor