S
Saeed Amrollahi
Dear all
Hi
I am Saeed Amrollahi. I write C++ programs using VC++ 2005 CLR/CLI. I
have two problems:
1. How to declare/define and use global ref class objects? For example
for database connection/communication, I usually define a class called
DBBroker, When I used MFC, DBBrk wraped the Recordset/ODBC facilities
and now it wraps the ADO.Net facilities:
ref class DBBroker { // A wrapper class for all database manipulation
public:
DBBroker();
void Open();
bool IsOpen();
void SetQuery(const std::wstring&);
void SetUpdQuery(const std::wstring&);
void SetInsQuery(const std::wstring&);
void Close();
/*
* Load functions
*/
std::map<std::wstring, std::wstring> LoadSQLFilename();
// ...
/*
* Get functions
*/
int GetNextAvailInvestorId();
// ...
/*
* Update functions
*/
void UpdAccLogin();
/*
* Insert functions
*/
void InsIndividual();
~DBBroker();
private:
System:ata::OleDb::OleDbConnection^ Conn;
System:ata::OleDb::OleDbCommand^ Command;
System:ata::OleDb::OleDbDataAdapter^ Adapter;
};
Now I want to define one and only one global object:
DBBroker^ g_DBBrk = gcnew DBBroker();
At the moment, I have to define a DBBroker object for each form and
database operation and obviously, it is base practice.
2. As you know, If I have the following native C++ class:
class C {
public:
C& f();
C& g();
};
then, I can write the following code:
C c;
c.f().g();
How to use the method chaining inside a ref class:
public ref class SingleInvestorRegForm : public
System::Windows::Forms::Form
{
public:
SingleInvestorRegForm^ FillNationalityComboBox();
SingleInvestorRegForm^ FillSexComboBox();
};
FillNationalityComboBox()->FillSexComboBox(); // or something like
that
Thanks in advance,
Regards,
S. Amrollahi
Hi
I am Saeed Amrollahi. I write C++ programs using VC++ 2005 CLR/CLI. I
have two problems:
1. How to declare/define and use global ref class objects? For example
for database connection/communication, I usually define a class called
DBBroker, When I used MFC, DBBrk wraped the Recordset/ODBC facilities
and now it wraps the ADO.Net facilities:
ref class DBBroker { // A wrapper class for all database manipulation
public:
DBBroker();
void Open();
bool IsOpen();
void SetQuery(const std::wstring&);
void SetUpdQuery(const std::wstring&);
void SetInsQuery(const std::wstring&);
void Close();
/*
* Load functions
*/
std::map<std::wstring, std::wstring> LoadSQLFilename();
// ...
/*
* Get functions
*/
int GetNextAvailInvestorId();
// ...
/*
* Update functions
*/
void UpdAccLogin();
/*
* Insert functions
*/
void InsIndividual();
~DBBroker();
private:
System:ata::OleDb::OleDbConnection^ Conn;
System:ata::OleDb::OleDbCommand^ Command;
System:ata::OleDb::OleDbDataAdapter^ Adapter;
};
Now I want to define one and only one global object:
DBBroker^ g_DBBrk = gcnew DBBroker();
At the moment, I have to define a DBBroker object for each form and
database operation and obviously, it is base practice.
2. As you know, If I have the following native C++ class:
class C {
public:
C& f();
C& g();
};
then, I can write the following code:
C c;
c.f().g();
How to use the method chaining inside a ref class:
public ref class SingleInvestorRegForm : public
System::Windows::Forms::Form
{
public:
SingleInvestorRegForm^ FillNationalityComboBox();
SingleInvestorRegForm^ FillSexComboBox();
};
FillNationalityComboBox()->FillSexComboBox(); // or something like
that
Thanks in advance,
Regards,
S. Amrollahi