wsyeager
Well-known member
I am using an OLEDB provider, and cant get the CommandTimeout property to work! I want the query to fire a CommandTimeOut exception if it is taking too long to run. Here is my code:
Public Function RunAdHocQuery(ByVal strDataSource As String, ByVal strQuery As String) As DataSet
Dim cnRpt As New OleDbConnection("Provider=MSDAORA.1;Password=ten;Persist Security Info=False;Password=ten;User ID=CVRSS;Data Source=" & strDataSource & ".FPL.COM")
Dim cnRpt As New OleDbConnection("Provider=OraOLEDB.Oracle.1;Password=ten;Persist Security Info=True;Password=ten;User ID=CVRSS;Data Source=" & strDataSource & ".FPL.COM")
Dim cmdRpt As New OleDbCommand(strQuery, cnRpt)
Dim daRpt As New OleDbDataAdapter(cmdRpt)
Dim ds As New DataSet()
Dim objDataAccess As New DataAccess()
Try
cmdRpt.CommandTimeout = 5
daRpt.SelectCommand = cmdRpt
ds = objDataAccess.GetOLEData(cnRpt, daRpt, cmdRpt, ds)
Catch exexception As TimeoutException
Throw (exException)
Catch exException As InvalidOperationException
Throw (exException)
Catch exException As ArgumentNullException
Throw (exException)
Catch exexception As NotSupportedException
Throw (exException)
Catch exException As OleDbException
Throw (exException)
Catch exException As Exception
Throw (exException)
Finally
If cnRpt.State = ConnectionState.Open Then
cnRpt.Close()
End If
objDataAccess = Nothing
cmdRpt.Dispose()
daRpt.Dispose()
cnRpt.Dispose()
End Try
Return ds
End Function
Is there any way that I can get the CommandTimeOut property to work???
Public Function RunAdHocQuery(ByVal strDataSource As String, ByVal strQuery As String) As DataSet
Dim cnRpt As New OleDbConnection("Provider=MSDAORA.1;Password=ten;Persist Security Info=False;Password=ten;User ID=CVRSS;Data Source=" & strDataSource & ".FPL.COM")
Dim cnRpt As New OleDbConnection("Provider=OraOLEDB.Oracle.1;Password=ten;Persist Security Info=True;Password=ten;User ID=CVRSS;Data Source=" & strDataSource & ".FPL.COM")
Dim cmdRpt As New OleDbCommand(strQuery, cnRpt)
Dim daRpt As New OleDbDataAdapter(cmdRpt)
Dim ds As New DataSet()
Dim objDataAccess As New DataAccess()
Try
cmdRpt.CommandTimeout = 5
daRpt.SelectCommand = cmdRpt
ds = objDataAccess.GetOLEData(cnRpt, daRpt, cmdRpt, ds)
Catch exexception As TimeoutException
Throw (exException)
Catch exException As InvalidOperationException
Throw (exException)
Catch exException As ArgumentNullException
Throw (exException)
Catch exexception As NotSupportedException
Throw (exException)
Catch exException As OleDbException
Throw (exException)
Catch exException As Exception
Throw (exException)
Finally
If cnRpt.State = ConnectionState.Open Then
cnRpt.Close()
End If
objDataAccess = Nothing
cmdRpt.Dispose()
daRpt.Dispose()
cnRpt.Dispose()
End Try
Return ds
End Function
Is there any way that I can get the CommandTimeOut property to work???