CommandTimeout

wsyeager

Well-known member
Joined
Apr 10, 2003
Messages
140
Location
Weston, FL
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???:mad:
 
RE:

Code:
here is the command that opens strQuery and cnRpt
Dim cmdRpt As New OleDbCommand(strQuery, cnRpt)

create adapter and fill with cmdrpt (strQuery and cnRpt)
Dim daRpt As New OleDbDataAdapter(cmdRpt)

creat dataaccess and also fill with cnRpt? Wont cause it to connect over and over in a loop?
ds = objDataAccess.GetOLEData(cnRpt, daRpt, cmdRpt, ds)

you are calling the commands and the adapter that already has a connections string built into it. There is no need to call it a second time.

cmdRpt-- connects to db
cnRpt -- also connects to db
ds -- add ds to ds?

shouldnt that line be somthing like
ds = objDataAccess.GetOLEData(daRpt)
that should have all the data you want in it already
 
This method is simply a middle-tier method. I developed an entire backend class that takes care of all data-access and data-updates. I have been using these methods for the past year os so with no problem.......
 
Back
Top