RE: C++ connection to OleDbConnection
- From: Gordon <Gordon@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 8 Dec 2006 09:24:00 -0800
Hi;
I finally figured out my problem.
You have to have two references in order for your declared object to
recognized.
Add them to your references folder in the solutions explorer.
They are:
System
System.Data
--
Gordon
"Gordon" wrote:
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
- References:
- C++ connection to OleDbConnection
- From: Gordon
- C++ connection to OleDbConnection
- Prev by Date: Re: Connect Table
- Next by Date: Re: column cannot contain null values - autoincrement column
- Previous by thread: C++ connection to OleDbConnection
- Next by thread: problem in inserting the data in sqldatabase .adp file
- Index(es):
Relevant Pages
|
Loading