Dear All,

I've created a database class in my project and I'm opening a db connection with that class whenever I need to query Db. However, it's very inefficient creata new database object in every function call and open a connection to database. For that reason I'm trying to change my implementation and create a static protected db object and open a connection once and close it when I finish all my queries.

So far, it sounds reasonable and easy

However, when I call "open" method of my database class from another class, I'm getting this error:
error C2662: 'Database::Open' : cannot convert 'this' pointer from 'const Database' to 'Database &'
How can I solve this problem?

My db header:
#define CATCHERROR(ptr,a)	catch(_com_error &e)\
								return a;\

#define CATCHERRGET			catch(_com_error &e)\
								sprintf(m_ErrStr,"%s\n**For Field Name:%s",m_ErrStr,FieldName);\
								return 0;\

#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
              rename("EOF", "EndOfFile")

typedef ADODB::_RecordsetPtr	RecPtr;
typedef ADODB::_ConnectionPtr	CnnPtr; 

class Database;
class Table;

class Database
	CnnPtr m_Cnn;
	char m_ErrStr[500];
	bool Open(char* UserName, char* Pwd,char* CnnStr);
	bool Close();
	bool OpenTbl(int Mode, char* CmdStr, Table& Tbl);
	bool Execute(const char* CmdStr);
	bool Execute(const char* CmdStr, Table& Tbl);
	void GetErrorErrStr(char* ErrStr);

class Table{
	RecPtr m_Rec;
	char m_ErrStr[500];
	void GetErrorErrStr(char* ErrStr);
	int ISEOF();
	HRESULT MoveNext();
	HRESULT MovePrevious();
	HRESULT MoveFirst();
	HRESULT MoveLast();
	int AddNew();
	int Update();
	int Add(char* FieldName, char* FieldValue);
	int Add(char* FieldName,int FieldValue);
	int Add(char* FieldName,float FieldValue);
	int Add(char* FieldName,double FieldValue);
	int Add(char* FieldName,long FieldValue);
	bool Get(char* FieldName, char* FieldValue);
	bool Get(char* FieldName, std::string& FieldValue);	
	int GetInt(char* FieldName);
	bool Get(char* FieldName,float& FieldValue);
	bool Get(char* FieldName,double& FieldValue);
	bool Get(char* FieldName,double& FieldValue,int Scale);
	bool Get(char* FieldName,long& FieldValue);
Trying to call it from this class:
#include "Database.h"
namespace Myclass
    class Myclass
		static const Database* dbObj;
And implementation:
if(!dbObj->Open(userIdValue, passwordValue, CnnStr)){}
Thanks in advance