# SQL query times out after 30 seconds regardless of config settings

**URL:** <https://forum.freecodecamp.org/t/sql-query-times-out-after-30-seconds-regardless-of-config-settings/299777>\
**Category:** General\
**Created:** [July 30, 2019, 5:00am UTC](https://forum.freecodecamp.org/t/sql-query-times-out-after-30-seconds-regardless-of-config-settings/299777 "2019-07-30T05:00:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RushabhVerma](https://avatars.discourse-cdn.com/v4/letter/r/ee7513/32.png) [@RushabhVerma](https://forum.freecodecamp.org/u/RushabhVerma)\
**Post date:** [July 30, 2019, 5:00am UTC](https://forum.freecodecamp.org/t/sql-query-times-out-after-30-seconds-regardless-of-config-settings/299777/1 "2019-07-30T05:00:49Z")

</div>

The problem is that I’m getting a timeout error while querying the database in a **for loop** to fetch paginated set of records. Each loop is not expensive, but querying for more than 30 seconds using the same connection object gives the transaction/timeout error :

I’ve tried adding commandTimeout property for Dapper query, and Connection Timeout in app.config (both being above 30 seconds), but it doesn’t affect anything.

```auto
int pages = totalCount / pageSize;
for(int pageNumber = 1; pageNumber <= pages; pageNumber++){
  string sql = @"select * from MyTable order by 1 desc offset @pageSize * (@pageNumber-1) rows fetch next @pageSize rows only;";
 _connection.Query<MyEntity>(sql, param: new {pageSize, pageNumber}).ToList();
}

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 9:33am UTC](https://forum.freecodecamp.org/t/sql-query-times-out-after-30-seconds-regardless-of-config-settings/299777/2 "2021-01-17T09:33:20Z")

</div>

Closed on January 17, 2021, 9:33am UTC


