简体   繁体   English

启用连接池时,dataadapter.fill命令在高负载下随机返回0行

[英]dataadapter.fill command randomly returns 0 rows under heavy load when connection pooling is enabled

We have been having issues with ADO.NET commands in ASP.NET applications, we have norrowed it down to this... 我们在ASP.NET应用程序中一直遇到ADO.NET命令的问题,因此将其归结到此。

No errors are returned but instead the dataadapter.fill command just returns 0 rows. 没有错误返回,而是dataadapter.fill命令仅返回0行。

This only happens some of the time, the vast majority of the time, the query executes normally. 这仅在查询正常执行的某些时间(大部分时间)中发生。 We know SQL server didn't return an error (using sql profiler), and the query should have returned a result (re-running the dataadapter.fill does return some rows and the rows have always existed in the database) This seems to happen only when we have ado.net connection pooling turned on and when the server is under heavy load. 我们知道SQL Server没有返回错误(使用sql profiler),并且查询应该已经返回了结果(重新运行dataadapter.fill确实返回了一些行,并且这些行始终存在于数据库中)这似乎发生了仅当我们打开ado.net连接池并且服务器处于高负载时。

We are using SqlClient connection/command objects and connecting to a SQL Server database (we've seen this behaviour with SQL 2005 and SQL 2008 so far) 我们正在使用SqlClient连接/命令对象并连接到SQL Server数据库(到目前为止,我们已经在SQL 2005和SQL 2008中看到了此行为)

Does the select statement return multiple resultsets? select语句是否返回多个结果集? If yes then you might want to use: 如果是,那么您可能要使用:

using(DbDataAdapter dataAdapter = _providerFactory.CreateDataAdapter())
{
  dataAdapter.TableMappings.AddRange(tableMappings);
  dataAdapter.SelectCommand = selectCommand;

  // This is crucial for HasChanges() to return the correct value
  dataAdapter.AcceptChangesDuringFill = false;

  MyTypedDataSet dataSet = new MyTypedDataSet();
  dataSet.EnforceConstraints = false;
  dataAdapter.Fill(dataSet);
  bool hasData = dataSet.HasChanges();
  return hasData;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM