C++ 我可以通过TADOConnection通过TEventDispatcher捕获SQL Server事件吗?
我正在尝试捕捉C++ 我可以通过TADOConnection通过TEventDispatcher捕获SQL Server事件吗?,c++,sql-server,c++builder,com+,adoconnection,C++,Sql Server,C++builder,Com+,Adoconnection,我正在尝试捕捉t数据连接上的断开连接。 我读过一篇又一篇的文章 我实现过这样的TEventDispatcher类 #include <utilcls.h> #include <ADOInt.hpp> class EventHandler : public TEventDispatcher<EventHandler,&DIID_ConnectionEvents> { private: bool connected; TForm1 *thefor
t数据连接
上的断开连接。
我读过一篇又一篇的文章
我实现过这样的TEventDispatcher
类
#include <utilcls.h>
#include <ADOInt.hpp>
class EventHandler : public TEventDispatcher<EventHandler,&DIID_ConnectionEvents>
{
private:
bool connected;
TForm1 *theform;
_Connection* server;
protected:
HRESULT InvokeEvent(DISPID id, TVariant *params);
public:
EventHandler();
~EventHandler();
void Connect(TForm1 *form, _Connection* srv);
void Disconnect();
};
EventHandler::EventHandler()
{
connected = false;
theform = NULL;
}
EventHandler::~EventHandler()
{
if (connected)
Disconnect();
}
handler->Connect(this,ADOConnection1->ConnectionObject);
我正在尝试这样使用EventHandler类
#include <utilcls.h>
#include <ADOInt.hpp>
class EventHandler : public TEventDispatcher<EventHandler,&DIID_ConnectionEvents>
{
private:
bool connected;
TForm1 *theform;
_Connection* server;
protected:
HRESULT InvokeEvent(DISPID id, TVariant *params);
public:
EventHandler();
~EventHandler();
void Connect(TForm1 *form, _Connection* srv);
void Disconnect();
};
EventHandler::EventHandler()
{
connected = false;
theform = NULL;
}
EventHandler::~EventHandler()
{
if (connected)
Disconnect();
}
handler->Connect(this,ADOConnection1->ConnectionObject);
< SQLServer手册停止时,为什么不调用<代码>调用> EventHandler > /Cux>类?< /P> Bu AARAR PASO C++ + HYIIR?您不能期望以这种方式接收意外事件的通知。只有当客户端知道连接丢失时,才会触发connectionLost事件。这可能不是在实际失去连接后的一段时间内。@Ben感谢您的评论。你能给我一个替代的解决方案吗?布阿拉尔Paso C++ + Hyidir?你不能期望以这种方式接收意外事件的通知。只有当客户端知道连接丢失时,才会触发connectionLost事件。这可能不是在实际失去连接后的一段时间内。@Ben感谢您的评论。你能给我其他的解决办法吗?