Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Runtime/XSharp.SQLRdd/Classes/Command.prg
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ class SqlDbCommand inherit SqlDbHandleObject implements IDisposable
return
end constructor

/// <summary>Apply the connection's CommandTimeout (when set) to the command.</summary>
private method _ApplyTimeout() as VOID
if SELF:Connection:CommandTimeout >= 0 .and. SELF:DbCommand != null
SELF:DbCommand:CommandTimeout := SELF:Connection:CommandTimeout
endif
RETURN

private method CallBack(cTable as STRING) as VOID
if withEvents
self:CommandText := SELF:Connection:RaiseStringEvent(self, SqlRDDEventReason.CommandText, cTable, self:CommandText)
Expand Down Expand Up @@ -158,6 +165,7 @@ class SqlDbCommand inherit SqlDbHandleObject implements IDisposable
method GetSchemaTable() as DataTable
try
self:Connection:ForceOpen()
SELF:_ApplyTimeout()
if ! SELF:_TryBindParameters()
return null
endif
Expand Down Expand Up @@ -310,6 +318,7 @@ class SqlDbCommand inherit SqlDbHandleObject implements IDisposable
if self:Connection:DbTransaction != null
self:DbTransaction := self:Connection:DbTransaction
endif
SELF:_ApplyTimeout()
if ! SELF:_TryBindParameters()
return null
endif
Expand Down Expand Up @@ -348,6 +357,7 @@ class SqlDbCommand inherit SqlDbHandleObject implements IDisposable
if self:Connection:DbTransaction != null
self:DbTransaction := self:Connection:DbTransaction
endif
SELF:_ApplyTimeout()
if ! SELF:_TryBindParameters()
return null
endif
Expand Down Expand Up @@ -376,6 +386,7 @@ class SqlDbCommand inherit SqlDbHandleObject implements IDisposable
if self:Connection:DbTransaction != null
self:DbTransaction := self:Connection:DbTransaction
endif
SELF:_ApplyTimeout()
if ! SELF:_TryBindParameters()
return false
endif
Expand Down
13 changes: 13 additions & 0 deletions src/Runtime/XSharp.SQLRdd/Classes/Connection.prg
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ class SqlDbConnection inherit SqlDbHandleObject implements IDisposable
end get
end property

/// <summary>
/// Time in seconds a statement may run before it is cancelled (0 = no limit, default -1 = the
/// ADO.NET provider's default, 30 seconds for SQL Server).
/// </summary>
/// <remarks>A count or an index on a table with millions of rows can take longer than the default. A
/// statement that times out is reported like any other error, which for a read means no rows.</remarks>
property CommandTimeout as long auto

/// <summary>Identifier Case as returned by the Ado.Net provider in the DataSourceInformation metadata collection.</summary>
property IdentifierCase as System.Data.Common.IdentifierCase auto get private set
/// <summary>Quoted Identifier Case as returned by the Ado.Net provider in the DataSourceInformation metadata collection.</summary>
Expand Down Expand Up @@ -266,6 +274,10 @@ class SqlDbConnection inherit SqlDbHandleObject implements IDisposable
if Int32.TryParse(strValue, out var cacheMs)
self:ResultCacheMs := cacheMs
endif
case "commandtimeout"
if Int32.TryParse(strValue, out var timeout)
self:CommandTimeout := timeout
endif
otherwise
builder:Add(key, strValue)
end switch
Expand Down Expand Up @@ -332,6 +344,7 @@ class SqlDbConnection inherit SqlDbHandleObject implements IDisposable
LegacyFieldTypes := DEFAULT_LEGACYFIELDTYPES
UseNulls := DEFAULT_USENULLS
UseLocks := DEFAULT_USELOCKS
CommandTimeout := -1
LongFieldNames := DEFAULT_LONGFIELDNAMES
TrimTrailingSpaces := DEFAULT_TRIMTRAILINGSPACES
PageSize := DEFAULT_PAGESIZE
Expand Down