C++ connection to OleDbConnection
- From: Gordon <Gordon@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 7 Dec 2006 14:01:01 -0800
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
.
- Follow-Ups:
- RE: C++ connection to OleDbConnection
- From: Gordon
- RE: C++ connection to OleDbConnection
- Prev by Date: Connect to XLS through ADO - Field names not coming through
- Next by Date: Re: Executing a StoredProcedure using ADOCommand object in ASP.NET
- Previous by thread: Connect to XLS through ADO - Field names not coming through
- Next by thread: RE: C++ connection to OleDbConnection
- Index(es):
Relevant Pages
|