Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2006, 01:18 AM
Authorized User
 
Join Date: Feb 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connection State in ADP

Hi guys,

How do I check the real state of my ADP connection to the database?

i.e. Supposed I am connected to the Database now. But due to some network problem, I am disconnected while I am running some process. I want to be able to tell that this connection is lost/broken.

Currentproject.Connection.State And Currentproject.Isconnected does not seem to work here as they will always return true if I have previously established the connection before the network problem.

Thanks in advance!


Scripts82
__________________
Scripts82
 
Old April 6th, 2006, 07:15 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Can't you run a second process to return a simple value, and if the value (recordset) is empty, then you can deduce you have lost the connection? (If you run it on the same connection) I admit, it is a kludge, but it monitors the connection nevertheless. Run the sample before your process, and if the recordset = 0, then reestablish the connection.

HTH


mmcdonal
 
Old April 6th, 2006, 08:32 PM
Authorized User
 
Join Date: Feb 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi mmcdonal, thanks for the help.

I get what you mean. In fact, I have a timer event that attempts to connect to a recordset and will prompt me when connection is lost.

The problem is, when I am scrolling through an ADO recordset and using on error resume next.

------------------------------------------------------
For example:

On error resume next
Do while not rs.eof
    debug.print rs![Column1]
    rs.movenext <-- connection gets disconnected here
loop
------------------------------------------------------

In the above situation, I will go into an endless loop. The timer does not have a chance to be "activated".
Of course I can choose not to use "On Error Resume Next",
but is there any other way to detect connection status cause otherwise, I will need to make quite a bit of changes to the program.




Scripts82
 
Old April 6th, 2006, 09:48 PM
Authorized User
 
Join Date: Feb 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi everyone,
Managed to solve the problem with a a for loop with DoEvents... this way, my timer will have a chance to be invoked and prompt the user to reconnect.

Thanks anyway

Scripts82





Similar Threads
Thread Thread Starter Forum Replies Last Post
adp slowness ginoitalo Access 1 November 6th, 2006 08:21 AM
Where is the processing done in ADP Scripts82 Access VBA 3 March 23rd, 2006 12:00 AM
Session State|View State|Do I have other options? rockon ASP.NET 1.x and 2.0 Application Design 2 October 5th, 2005 07:10 PM
Connection issues with ADP file tdl6281 Access 7 June 19th, 2004 01:54 PM
ADP connection error lhedquist Access 6 April 29th, 2004 09:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.