Link to home
Start Free TrialLog in
Avatar of KKWohlgemuth
KKWohlgemuth

asked on

Setting Currentproject.Connection.Commandtimeout

I have a report with the recordsource set to the name of a valid stored procedure.  I am assuming that in this situation, the connection that is used is currentproject.connection and that the timeout value for executing this report's recordsource is 30 seconds, the value of currentproject.connection.commandtimeout.

On an XP machine (using Office XP with SP1 applied), the report timeouts at 30 seconds.  On 95/98/Me machines (using Office 2000 with SR-2 applied), the report executes just fine and, by the way, takes longer than 30 seconds to run.

Is it possible to change the value of currentproject.connection.commandtimeout to 0 so I don't have to worry about this timeout?  I tried through code with no success.  Maybe there is another perspective to try ... help!  Thanks!
Avatar of dapperry
dapperry

The commandtimeout is read-only for open connections. Therefore, the CurrentProject.connection.commandtimeout will always be read-only. A couple of things you might want to consider:

1) I'm not sure if this is the same thing, but you can change the value of the connect timeout of the project by clicking on File | Connection... and then changing it in the Advanced tab of the dialog.

2) Of course you could always make a new connection, set the commandtimeout to 0, set the connectionstring to currentproject.connection.connectionstring, and then open the new connection object.

Hopefully, one of these suggestions will work for you.

:) dapperry
Avatar of KKWohlgemuth

ASKER

daperry,

Thanks for your suggestions...

1) This was one of the first things I played with.  It seems to me though, that this is simply a timeout for the project file trying to establish its connection with the identified SQL Server database.

2) This is along the lines of some things I pondered/tried.  But how can I set the reports and forms to use this new connection object?  There seems to be internal .adp connection and command objects that aren't exposed for developers like myself to modify except through Microsoft's interfaces within the project file environment.

Unless I am misunderstanding something, it appears my problem still lingers on ... thanks anyhow!
daperry,

Thanks for your suggestions...

1) This was one of the first things I played with.  It seems to me though, that this is simply a timeout for the project file trying to establish its connection with the identified SQL Server database.

2) This is along the lines of some things I pondered/tried.  But how can I set the reports and forms to use this new connection object?  There seems to be internal .adp connection and command objects that aren't exposed for developers like myself to modify except through Microsoft's interfaces within the project file environment.

Unless I am misunderstanding something, it appears my problem still lingers on ... thanks anyhow!
Hi,
      Try this bit of code, in your report open event:

Dim con As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String

con.ConnectionString = CurrentProject.Connection.ConnectionString
con.CommandTimeout = 0
con.Open

strSQL = "SELECT * FROM MyTable"
Set rst = con.Execute(strSQL)

Me.Recordset = rst

'Close up shop
Set rst = Nothing
Set con = Nothing

Haven't had time to test it, but it should work.

:) dapperry
dapperry, thanks again for your suggestion ... setting a report's recordset isn't allowed, unfortunately. In your above sample code, "me.recordset = rst" isn't a valid statement.
-----
Specifically, I want to change the "internal default connection's commandtimeout value" from it's current value of 30 to 0.
-----
Maybe there's a registry setting I could alter ... I don't know ... I need to find an answer!  I'm increasing the points to 500 ... Thanks in advance for any help!
whoops, can't exceed 300 points, sorry
for KKWohlgemuth

No comment has been added for the last two months.
So it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
 - PAQ'd and pts refunded
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Its been a while for this question, but try setting OLE/DDE Timeout to 0 under tools/options