Skip to content

Commit 2fd9868

Browse files
committed
Fixed the max number of parameters so that we will never exceed the limit when sp_prepexec is used.
1 parent 2375c6d commit 2fd9868

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/NHibernate/AdoNet/GenericBatchingBatcher.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ public GenericBatchingBatcher(ConnectionManager connectionManager, IInterceptor
3131
StatementTerminator = statementTerminator;
3232
_currentBatch = new BatchingCommandSet(this);
3333
// On Sql Server there is a limit of 2100 parameters, but 2 are reserved for sp_executesql, so
34-
// we are able to use up to 2098 parameters. The same applies for sp_prepexec.
34+
// we are able to use up to 2098 parameters. When sp_prepexec is used for preparing and executing
35+
// statements then one more parameter is used. Set the max number of parameters to 2097 in order
36+
// to ensure that we will never exceed the limit.
3537
if (Factory.Dialect is MsSql2000Dialect)
3638
{
37-
_maxNumberOfParameters = 2098;
39+
_maxNumberOfParameters = 2097;
3840
}
3941
// We always create this, because we need to deal with a scenario in which
4042
// the user change the logging configuration at runtime. Trying to put this

0 commit comments

Comments
 (0)