Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here is the environment that I have
Windows 7 (64 bit)
Visual Studio 2005
MS Access 2010 (64 bit)

I have to create a simple form application that connects to an MS access database and exchange data. I am struggling to establish the connection and have explored many resources online.
Here is the code that I am using:

C#
System::String^ connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Astute Database\db_retailpro.accdb;Persist Security Info=False;";

System::Data::OleDb::OleDbConnection^ connection = gcnew System::Data::OleDb::OleDbConnection(connectionString);

try
{
    connection->Open();
    Console::WriteLine("DataSource: {0} \nDatabase: {1}", connection->DataSource, connection->Database);
}
catch (Exception^ ex)
{
    Console::WriteLine(ex->Message);
}


This is throwing the following exception:
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll

Somebody please advise what could be the problem?

An update on this. Now I have found that the message in the catch block says "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."
What now?
Posted
Updated 17-Feb-14 23:38pm
v2
Comments
KarstenK 18-Feb-14 4:13am    
is it really the full name of the db: C:\Astute Database\db_retailpro.accdb;

Check out for a typo :-O
don_rocks 18-Feb-14 4:32am    
Thanks for the response KarstenK. Yes I checked for the typo.
An update on this. Now I have found that the message in the catch block says "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."
What now?

 
Share this answer
 
Comments
don_rocks 18-Feb-14 5:15am    
The MDAC is not for Windows 7 I guess.
Supported Operating System
Windows 2000, Windows 98, Windows ME, Windows NT
Available for x86-based computers only.
Finally solved the issue. This is the link that helped me.


http://social.msdn.microsoft.com/Forums/en-US/1d5c04c7-157f-4955-a14b-41d912d50a64/how-to-fix-error-the-microsoftaceoledb120-provider-is-not-registered-on-the-local-machine?forum=vstsdb[^]

Also I added another slash in the data source location for the escape sequence.
 
Share this answer
 

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