Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 我可以通过TADOConnection通过TEventDispatcher捕获SQL Server事件吗?_C++_Sql Server_C++builder_Com+_Adoconnection - Fatal编程技术网

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感谢您的评论。你能给我其他的解决办法吗?