Click to See Complete Forum and Search --> : Cant connect to database in visual c++ 2005


2MuchRiceMakesMeSick
October 24th, 2006, 03:35 AM
OleDbCommand aCommand = gcnew OleDbCommand();


gives me the error


Form1.h(173) : error C2248: 'System::Data::OleDb::OleDbCommand::OleDbCommand' : cannot access private member declared in class 'System::Data::OleDb::OleDbCommand'


i have
using namespace System::Data::OleDb;
defined at the top

anyone know why I get this error?

davide++
October 24th, 2006, 08:00 AM
Hi all.

The error that you got isn't a database connection error, but a compile error; you're trying to call a private member of a class, and it isn't permitted (as you can read from error message).
Moreover, I find quite strange that this error comes from a header file.

I think you should read your documentation about managing database with OleDb library.

Are you using C#?

2MuchRiceMakesMeSick
October 24th, 2006, 09:01 AM
Turns out simply adding a ^ to the line worked.

OleDbCommand aCommand = gcnew OleDbCommand();

to

OleDbCommand ^ aCommand = gcnew OleDbCommand();