Northwind connection issue

G

Guest

I am learning to program C++ .net and am having difficulty with one of the
exercises and wondered if someone could help?
I am including the code for a console app I wrote according to the exercise
that is supposed to create a connection to the
Northwind.mdb database. I modified the code for the ConnectionString to
include the path to where I found Northwind.mdb
to be located on my machine. When I run the program, I get the following
error:

An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll Additional information:
The 'Microsoft.Jet.OLEDB.4.0: Data Source=C:\Program Files\Microsoft
Office\Office\Samples\northwind.mdb' provider is not
registered on the local machine.

Can anyone help me?

// This is the main project file for VC++ application project // generated
using an Application Wizard. #include "stdafx.h" #using using namespace
System; //Generic ADO.NET definitions using namespace System::Data;
//specific Oledb provider definitions using namespace System::Data::OleDb;
int _tmain() { //create a connection OleDbConnection* cnNwind = new
OleDbConnection(); //Set the connection string cnNwind->ConnectionString = S"
Provider=Microsoft.Jet.OLEDB.4.0: " S"Data Source=C:\\Program
Files\\Microsoft Office\\Office\\Samples\\northwind.mdb"; try { //Open the
database cnNwind->Open(); Console::WriteLine(S"Connected to database
successfully!"); } catch(OleDbException* pe) { Console::Write(S"Error
occurred: "); Console::WriteLine(pe->Message); } //Close the connection if
(cnNwind->State != ConnectionState::Closed) { cnNwind->Close(); }
Console::WriteLine(S"The database connection is now closed"); return 0; }
 
G

Guest

Hi,

You have a bug in your connection string:
S"Provider=Microsoft.Jet.OLEDB.4.0:" ...blabla
There should be semicolon instead of colon
S"Provider=Microsoft.Jet.OLEDB.4.0;" ...blabla

Hope this helps
 
G

Guest

That did it!!!!
Thanks so much for replying!

Milosz Skalecki said:
Hi,

You have a bug in your connection string:
S"Provider=Microsoft.Jet.OLEDB.4.0:" ...blabla
There should be semicolon instead of colon
S"Provider=Microsoft.Jet.OLEDB.4.0;" ...blabla

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top