How to link and ODBC table to MS Access database using VB and without connecting to the server?

StackOverflow https://stackoverflow.com/questions/23249865

  •  08-07-2023
  •  | 
  •  

Question

I have a VB procedure that changes a connection string for all 360 linked tables in my Access 2002 database. If I run this procedure using an SQL server in my local network, it runs about 30 seconds. The problem is that I have to use an SQL server somewhere in the Internet. In this case the procedure runs for about 5 minutes. The question is - how can I prevent Access from connecting to the server to check every table I re-connect?

An alternative question (maybe more correct). I need to run that re-connection procedure on every user's computer every time I give them a new version of the database, to save user's login and password into every linked table. Maybe there is some other way to set the username and password for the ODBC connection?

Was it helpful?

Solution

Linked tables do NOT all of a sudden decide to connect to some some server. So the recommend approach here is to link the tables once (and leave the password + user name OUT of the link).

Then on startup, all you do is execute ONE logon command and then ALL OF THE tables are instant available and able to be used WITHOUT any re-link or re-fresh of the conneciton string. Same goes for any pass-ghouth queries etc.

So the existence of a linked table IS NOT USED on startup and you can have 3 or 300 linked tables and launch Access WILL NOT cause a connection to occur “unless” you decode to do something like a re-link.

Bottom line: You don’t and should not re-link on startup You do not need to include the user name + password in the table links.

A ONE TIME logon at startup will cause Access to “cache” the user name + password and this will be used for ALL CURRENT EXISTING table links. The beauty of this is when the user exits the applctaion then no passwords etc. are stored in the linked tables.

So you cannot prevent access from connecting to the server during a table re-link since that what it must do.

However there is LITTLE if not ZERO reason to re-link every time on startup? Why are you doing a re-link are startup?

I need to run that re-connection procedure on every user's computer every time I give them a new version of the database,

Why not link the database on your machine BEFORE you distribute it to that user? After all the connection is over the internet – so you should be able to link to that database system from your development computer. And assuming you cannot, then ok, perhaps you might beforced to do a ONE time re-link. Try the re-link with a cached logon – it likely will run faster, but then again it will only be a one time re-link anyway.

save user's login and password into every linked table.

NO NO this is NOT required nor is recommended. If a user holds their mouse over a linked table then if you included the user name + password it is in plan view.

You DO NOT want to include the user name + password in each linked table. How to execute a SINGLE logon and have that logon used for ALL tables (without a re-link) and for ALL tables EVEN without the user id + password saved is outlined here:

Power Tip: Improve the security of database connections

http://blogs.office.com/b/microsoft-access/archive/2011/04/08/power-tip-improve-the-security-of-database-connections.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top