Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.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# C++;使用ADO.NET库 我有一个C++应用程序,它必须对SQL数据库中保存的状态更改做出反应。他们必须实时做出反应,目前这是通过轮询完成的。然而,我需要的实时响应时间是数据库过载_C#_C++_Ado.net_Query Notifications - Fatal编程技术网

C# C++;使用ADO.NET库 我有一个C++应用程序,它必须对SQL数据库中保存的状态更改做出反应。他们必须实时做出反应,目前这是通过轮询完成的。然而,我需要的实时响应时间是数据库过载

C# C++;使用ADO.NET库 我有一个C++应用程序,它必须对SQL数据库中保存的状态更改做出反应。他们必须实时做出反应,目前这是通过轮询完成的。然而,我需要的实时响应时间是数据库过载,c#,c++,ado.net,query-notifications,C#,C++,Ado.net,Query Notifications,我读过SQLServer2005中引入的查询通知,但实际上我并不真正了解可用的不同SQL连接方法。目前,我使用ADO.NET来简化数据库通信,但我找到的唯一用于执行这种性质的查询通知的示例代码是C#和VB。更不用说我正在努力理解这个概念。下面是我当前如何使用ADO.NET运行SQL的示例 hr = link.CreateInstance(__uuidof(Connection) ); if (link) { // Execute the query on the ope

我读过SQLServer2005中引入的查询通知,但实际上我并不真正了解可用的不同SQL连接方法。目前,我使用ADO.NET来简化数据库通信,但我找到的唯一用于执行这种性质的查询通知的示例代码是C#和VB。更不用说我正在努力理解这个概念。下面是我当前如何使用ADO.NET运行SQL的示例

    hr = link.CreateInstance(__uuidof(Connection) );

        if (link) { // Execute the query on the open connection using existing command object

        pCommand.CreateInstance(__uuidof(Command));
        pCommand->ActiveConnection = link;
        pCommand->CommandType = ado20CommandType;
        pCommand->CommandText = strQuery.GetBuffer(0);
        pCommand->PutPrepared(true);
        pCommand->NamedParameters = true;

            if (pRecordSet = pCommand->Execute(&vRecordsAffected,NULL,NULL)) {  // Execute the final query and set object-level recordset object
            lRecordsAffected = vRecordsAffected.lVal;

            _RecordsetPtr pfuRecordSet = link->Execute(_T("SELECT @@IDENTITY as pmIDENT;"),NULL,adCmdText);
            CString strID = pfuRecordSet->GetFields()->GetItem(COleVariant("pmIDENT"))->Value.bstrVal;
            int nID = atoi(strID);
            if (nID > 0) {
                nLastInsertedID = nID;
            }

            return true;
        }

我想知道是否有人能提供我的资源和/或代码,这将帮助我在C++中设置这个代码。提前感谢。

从SQL Server数据库中获取数据的最快方法是使用SqlDataReader,它是只读的,仅向前

看看这个C++代码,试试看。


在网上请求资源的问题与SO无关。你需要问一些你遇到的具体问题。一个潜在的解决办法是创建一个C项目,并从C++调用它。真棒谢谢,是的,这是我不太清楚的地方。所以当我想写我假设的查询时,我必须在ado.net代码的旁边实现sqldatareader。。。这很简单。但是sqldatareader可以支持查询通知吗?或者这只是使用ado.net读取的另一种更快的方法吗?我的研究建议使用前者。是的,您可以将SqlDataReader与SqlDependency(C#解决方案)和AddCacheDependency(C#解决方案)一起使用