数据无法插入MS-Access 2010的数据库中 [英] Data could not insert into database of MS-Access 2010

查看:88
本文介绍了数据无法插入MS-Access 2010的数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System.Data.OleDb;

OleDbConnection connection = new OleDbConnection();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\ABC\db.mdb;";

connection.Open();

OleDbCommand cmd = new OleDbCommand("INSERT into TaxSale(CauseNumber,Address)Values(@CauseNumber,@Address)", connection);

cmd.Parameters.Add("@CauseNumber", OleDbType.VarChar).Value = _CollectValue[0];
cmd.Parameters.Add("@Address", OleDbType.VarChar).Value = _CollectValue[1];

cmd.ExecuteNonQuery();
connection.Close();





我有一个例外InvalidOperationException未处理且未处理System.Data.dll中出现'System.InvalidOperationException'类型的异常



我使用VS 2013和MS访问数据库,Microsoft office 2010.

此代码在Windows 7 32位操作系统上运行。不能在Windows 7 64位操作系统上运行。

请给我解决方案。



I have one exception "InvalidOperationException was unhandled and An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll"

I use VS 2013 and MS access database, Microsoft office 2010.
This code run on windows 7 32-bit OS. Not run on Windows 7 64-bit OS.
please give me solution.

推荐答案

Access数据库提供程序根本无法运行64位进程。您必须编译x86平台的应用程序。然后它将在64位操作系统上运行,但就像32位进程一样。



如果由于某种原因,您的应用程序的其他部分需要在64位进程中运行您别无选择,只能将你的应用程序分成两个部分,一个是x86部分,正在执行Access-DB-Stuff,一个是64位部分,让它们以某种方式进行通信。
The Access Database Provider simply doesn't work in a 64 bit Process. You have to compile your application for x86 platform. It will then run on 64 bit OS but just as a 32 bit Process.

If for some reason other parts of your application need to run in a 64 bit Process you have no other choice than splitting your application into two parts, one x86 part that's doing the Access-DB-Stuff and one 64 bit part and let them communicate in some way.


这篇关于数据无法插入MS-Access 2010的数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆