etm124
etm124

Reputation: 2140

Adding QueryTimeout parameter to command string

I have a small web app that runs sql queries for users, that prints the results to pdf/csv. For larger queries, I am getting this error:

ERROR [57014] [IBM][DB2/AIX64] SQL0952N  Processing was cancelled due to an interrupt.  SQLSTATE=57014

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: IBM.Data.DB2.DB2Exception: ERROR [57014] [IBM][DB2/AIX64] SQL0952N  Processing was cancelled due to an interrupt.  SQLSTATE=57014

After doing research, It turns out I need to add a QueryTimeout parameter to my connection string. I don't have much experience with vb.net aside from some simple edits. My relevant code looks like this:

Imports IBM.Data.DB2
Dim conn As New DB2Connection(ConfigurationManager.AppSettings(ddDatabase.SelectedValue))
Dim cmd As New DB2Command(strSQL, conn)

Upvotes: 0

Views: 1087

Answers (1)

Steve
Steve

Reputation: 216313

If I understand your problem I think you should set the CommandTimeout on the DB2Command not the max time allowed to establish the connection

Imports IBM.Data.DB2
Dim conn As New DB2Connection(ConfigurationManager.AppSettings(ddDatabase.SelectedValue))
Dim cmd As New DB2Command(strSQL, conn)
cmd.CommandTimeout = 200

DB2.CommandTimeout

The time (in seconds) to wait for the command to execute. The default is 30 seconds.

Upvotes: 1

Related Questions