Skip to content

SQLRDD: CommandTimeout connection option - #2134

Merged
RobertvanderHulst merged 1 commit into
X-Sharp:devfrom
ecosSystem:homebase/sqlrdd-command-timeout-v2
Oct 28, 2026
Merged

RobertvanderHulst merged 1 commit into
X-Sharp:devfrom
ecosSystem:homebase/sqlrdd-command-timeout-v2

Conversation

@ecosSystem

Copy link
Copy Markdown
Contributor

The RDD had no way to set the timeout of its statements, so every statement ran with the provider default (30 seconds for SQL Server). On large tables some statements take longer: creating an index on a table with millions of rows, a count, or an import. They were cancelled after 30 seconds and reported like any other error, which for a read means no rows.

What changed

  • New connection property and connection string option CommandTimeout: the time in seconds a statement may run before it is cancelled. 0 means no limit; the default -1 keeps the provider default, so nothing changes unless it is set.
  • SqlDbCommand applies it to the ADO.NET command before every execution (ExecuteReader, ExecuteScalar, ExecuteNonQuery, GetSchemaTable).
Server=...;Initial Catalog=...;CommandTimeout=300

or at run time, e.g. for a maintenance step:

var nTimeout := oConn:CommandTimeout
oConn:CommandTimeout := 0
// ... create indexes, import ...
oConn:CommandTimeout := nTimeout

Testing

Our ERP has used it since moving a customer dataset (72 GB, tables with up to 14 million rows) to SQL Server: the connection gets CommandTimeout from its configuration, and the synchronisation at program start (import of the DBF data, creating and rebuilding indexes) runs with 0. The import (more than two hours, single CREATE INDEX statements of several minutes) and a rebuild of 316 indexes (20 minutes) ran without timeouts. Without the option set, the behaviour is unchanged.

🤖 Generated with Claude Code

Every statement ran with the ADO.NET provider's default timeout (30 s for
SQL Server), and there was no way to change it. With tables of millions of
rows a count, an index or a first page of a function-key order can take
longer; the statement is then cancelled and reported as an error, which for
a read means no rows.

The new connection option CommandTimeout (seconds, 0 = no limit, default -1
= the provider's default) is applied to every SqlDbCommand before it runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RobertvanderHulst
RobertvanderHulst merged commit 0de5d03 into X-Sharp:dev Oct 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants