Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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();


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.
Posted
Updated 24-Feb-15 22:00pm
v2
Comments
[no name] 25-Feb-15 3:58am    
(edit): Solution
Hrishikesh Durugkar 25-Feb-15 4:28am    
OK, but have any other solution for solve this problem.

1 solution

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.
 
Share this answer
 
v3
Comments
Hrishikesh Durugkar 25-Feb-15 4:26am    
OK, but have any other solution for solve this problem. @manchanx
[no name] 25-Feb-15 4:35am    
I have edited my above solution - does this help?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900