Skip to main content

IBM.Data.DB2.iSeries Class

Error Message: Object reference not set to an instance of an object.
or

IBM.Data.DB2.iSeries.iDB2SQLErrorException: SQL0666 Estimated query processing time 56 exceeds limit 30.



Private Sub btnUpdate1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate1.Click

Dim cn As iDB2Connection = New iDB2Connection("User ID=me;Password=me;Data Source=TESTIP;Connection Timeout = 0")

cn.Open()

Dim strQuery As String = String.Empty

strQuery = "Select * from Employee"

Dim cmd As iDB2Command = New iDB2Command(strQuery, cn)

cn.Close()

End Sub

================================================================
SOLUTION: The iDB2Command command timeout must be set to 0 (zero) to override the default of 30. If your job is estimated to run longer than 30 seconds you will receive an exception.



Private Sub btnUpdate1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate1.Click

Dim cn As iDB2Connection = New iDB2Connection("User ID=me;Password=me;Data Source=TESTIP;Connection Timeout = 0")

cn.Open()

Dim strQuery As String = String.Empty

strQuery = "Select * from Employee"

Dim cmd As iDB2Command = New iDB2Command(strQuery, cn)

cmd.CommandTimeout = 0

cn.Close() End Sub



TIP:

Add a Try, Catch Statement to find exception details. By using Try and Catch blocks, you separate error-handling statements from your logic. The ensures easier debugging.



If my blunders have helped you at all, please feel free to feed my ego and leave me a message.

Comments

Anonymous said…
Thanks your site was so helpful...I look forward to you leaving more post.