Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am using an OLEDB provider, and can't 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:

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Posted

RE:

 

'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

Posted
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.......

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...