Hello,
I dynamically build a DB2 query. I want to stop the request to the Database if it takes more than 5 minutes to get back a result.
I tried to add a Timeout on the connection and on the command, with no success. It's never poping up an error and I don't know how to do this.
Here is my code:
Try
cn = New OdbcConnection(ConfigurationSettings.AppSettings("Conndb2"
)
cn.ConnectionTimeout = 1
Dim mystring As String = sbSelect.ToString & sbFrom.ToString & sbWhere.ToString
Dim cmd As OdbcCommand = New OdbcCommand(mystring)
cmd.CommandType = CommandType.Text
cmd.CommandTimeout = 1
cn.Open()
Dim da As New OdbcDataAdapter(mystring, cn)
da.Fill(ds, "office"
ListBox.DataSource = ds
ListBox.DataBind()
Catch exc As Exception
lblMsg.Text = "<SCRIPT language = 'javascript'>alert('Error: " & "\n\n" & exc.Message & "');</SCRIPT>"
Finally
cn.Close()
End Try
Can you help me ?
I dynamically build a DB2 query. I want to stop the request to the Database if it takes more than 5 minutes to get back a result.
I tried to add a Timeout on the connection and on the command, with no success. It's never poping up an error and I don't know how to do this.
Here is my code:
Try
cn = New OdbcConnection(ConfigurationSettings.AppSettings("Conndb2"
cn.ConnectionTimeout = 1
Dim mystring As String = sbSelect.ToString & sbFrom.ToString & sbWhere.ToString
Dim cmd As OdbcCommand = New OdbcCommand(mystring)
cmd.CommandType = CommandType.Text
cmd.CommandTimeout = 1
cn.Open()
Dim da As New OdbcDataAdapter(mystring, cn)
da.Fill(ds, "office"
ListBox.DataSource = ds
ListBox.DataBind()
Catch exc As Exception
lblMsg.Text = "<SCRIPT language = 'javascript'>alert('Error: " & "\n\n" & exc.Message & "');</SCRIPT>"
Finally
cn.Close()
End Try
Can you help me ?