Command.Connection wants a handle (^) to a System::Data::Common::DbConnection
public:
property OdbcConnection^ Connection {
OdbcConnection^ get ();
void set (OdbcConnection^ value);
}
Instead try to do this:
System::Data::Odbc::OdbcCommand Command;
Command.Connection = %Connection;
The unary % operator (Tracking reference) returns a CLI tracking references to a CLI object. Tracking references are valid to handles and value types.
Response to comment:
When you create a managed object this way:
OdbcConnection Connection;
It's a special type of C++/CLI object that are allocated on the stack and that points to the managed object on the managed heap. It isn't a valid managed reference object. To create a managed reference you need to do the following.
OdbcConnection^ Connection; // In the class definition
// In the class constructor do the following:
Connection = gcnew OdbcConnection();
And DB connection should be deleted in the constructor to guarantee timely clean up. But it is not needed for managed object, they are delete automatically