By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

Northwind connection issue

P: n/a
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; }
Jan 18 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
--
Milosz Skalecki
MCP, MCAD
"JohnnyBoy" wrote:
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; }

Jan 18 '06 #2

P: n/a
That did it!!!!
Thanks so much for replying!

"Milosz Skalecki" wrote:
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
--
Milosz Skalecki
MCP, MCAD
"JohnnyBoy" wrote:
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; }

Jan 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.