Solved

Intercepting SQL Server connection errors in Access VBA code, over a VPN

Posted on 2014-03-06
6
1,053 Views
Last Modified: 2014-06-26
I have an Access application that is running on the computers of numerous individuals at one of my clients, running various different versions of Windows and Office.  We have migrated a number of tables to SQL Server but the connection strings for the different computer configurations are different, so I have a function which attempts to open a pass-thru query that selects the first record from one of the tables on the SQL server.  If that process raises an error, the error handler attempts several other connection strings until it finds the proper one for the current users computer; that part works fine.

However, some of the users of the application do so over a VPN, with the application on their home or laptop and if they have failed to open the VPN connection prior to running the application, the receive the following error message:
Connection Failed:
SQLState: '01000'
SQL Server Error: 53
[Microsoft][ODBC SQL Server Driver][DBNETLIB][ConnectionOpen(Connect()).
Connection Failed:
SQLState: '08001'
SQL Server Error: 17
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not
exist or access is denied.

Open in new window

which is not intercepted by the Access error handler.  How can I intercept that error and handle it cleanly within my application?  Or is their some easy to test whether the VPN connection is open?
0
Comment
Question by:Dale Fye (Access MVP)
6 Comments
 
LVL 42

Expert Comment

by:EugeneZ
ID: 39911464
here you are:

Potential causes of the "SQL Server does not exist or access denied" error message
http://support.microsoft.com/kb/328306

looks like you are using DSN ODBC that may need to be checked with potential adjustment of uid\pwd sql server name there and verification of the sql uid\pwd sql server name  by attempt to login on sql server via ssms to make sure that "sql server exists and used sql login has access to sql server\DB there"
0
 
LVL 16

Expert Comment

by:DcpKing
ID: 39911537
Take one of the machines home with you and set it up on your home network. You'll get an IP something like 192.168.0.4 or 192.168.1.5. There's a list available of class C addresses that can be used by anyone because they're kept behind a NAT and not seen by the outside world - hence lots of people have the same IP addess but don't collide.

Anyhow, then open up the VPN and everything and get into your work network. At this point you'll be on another network and you'll probably have a different address range - 10.something, in all likelihood.

Anyhow, have a server in work that Access can try to find: if it does then it's operating via the VPN, and if not it can tell the user to open up the connection.

hth

Mike
0
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 200 total points
ID: 39912233
I think I would simply take the server name from the connect string and try to ping it.  That will tell you if the network is up or not.

Jim.
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 24

Accepted Solution

by:
Bitsqueezer earned 300 total points
ID: 39915519
Hi,

in all connection strings always use the FQDN (full qualified domain name) and not only the name of the server. As an alternative you can also use the IP address but it's better to use the FQDN as an IP address could change sometimes (not very often in case of servers).

Sometimes a big network is divided into several subnets and without the FQDN it only searches in the direct reachable subnet and not all the others (depending on your network configuration).

Cheers,

Christian
0
 
LVL 47

Author Comment

by:Dale Fye (Access MVP)
ID: 39957685
Have not been able to pursue this as I've been working several other short suspense tasks.  Hope to get back to this soon.
0
 
LVL 47

Author Closing Comment

by:Dale Fye (Access MVP)
ID: 40161420
Thanks guys.  Finally got back to this decided to use Christian's method but liked Jim's approach as well.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now