C++ connection to OleDbConnection



Hi;

Could someone point out my code error here.

When I try to compile I get a C2065 OleDbConnection undeclared identifier
error

msg.

Here is my code:


#using <mscorlib.dll>

#using <System.Data.dll>
using namespace System;
using namespace System::Data;
using namespace System::Data::OleDb;

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{

// The connection
//string cnNwind;

OleDbConnection * conn = new OleDbConnection();

conn->ConnectionString = S "Provider=Microsoft.Jet.OLEBD.4.0; "
S"Data Source=C:\my_databases\taxLots.mdb";


// The connection string

try
{
// Open Database
conn->Open();
Console::WriteLine(S"Connected to database successfully!");
}
catch (OleDbException * pe)
{
Console::Write(S"Error occurred: ");
Console::WriteLine(pe->Message);
}

// Close Connection
if (conn->State != ConnectionState::Closed)
{
conn->Close();
}
Console::WriteLine(S"The database connection is now closed");

return 0;
}

Thanks for any insights.


--
Gordon
.



Relevant Pages

  • Connecting an ADO.net database via C++.net
    ... Could someone point out my code error here? ... I am trying to use the OleDbConnection object. ... using namespace System; ... // The connection string ...
    (microsoft.public.dotnet.languages.vc)
  • RE: C++ connection to OleDbConnection
    ... Add them to your references folder in the solutions explorer. ... When I try to compile I get a C2065 OleDbConnection undeclared identifier ... using namespace System; ... // The connection string ...
    (microsoft.public.data.oledb)