这是给您的代码测验 [英] Here is a code quiz for you

查看:54
本文介绍了这是给您的代码测验的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class IAlarmDatabase
{
public:
  IAlarmDatabase()        {}
  virtual~IAlarmDatabase(){}
  virtual bool OpenConnect(string strDataSource, string strUID, string strPwd) = 0;
  virtual bool ExecuteSql	(string strSql) = 0;
};

class CAlarmDatabase:public IAlarmDatabase
{
public:
	CAlarmDatabase();
	~CAlarmDatabase();
public:
	static CAlarmDatabase*	Instance();
	bool OpenConnect(string strDataSource, string strUID, string strPwd);
	bool ExecuteSql(string strSql);
protected:
	static auto_ptr<calarmdatabase> m_ADOInstance;
	_ConnectionPtr	m_pConnect;
	_RecordsetPtr	m_pRecordset;

};
</calarmdatabase>


该类旨在操作oracle数据库!
有人告诉我为什么?


the class is designed to operate oracle database!
someone tell me why?

推荐答案

当然不是!我用一些我们网站无法识别的语言发布问题...

我要问的是我创建一个_ConnectionPtr对象并调用它的open方法来打开与oracle数据库的连接,但是由于那里的代码,当我关闭该应用程序时出现_com错误?为什么? _connectionPtr无法释放自身?
of course not!I post the question with some languages that our website can''t recognize so ...

What I what to ask is I Create a _ConnectionPtr object and call it''s open method to open a connection with the oracle database,but as the code up there,When I shut the app a _com error occurs?why ? the _connectionPtr can''t release itself?


您应该在释放m_pConnect->Close()之前先调用它.
在这里:~CAlarmDatabase(),是个好地方.
You should call m_pConnect->Close() before releasing it.
Here: ~CAlarmDatabase(), is a good place.


这篇关于这是给您的代码测验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆