473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Access 2010 and Server Name on DSN in ODBC Data Source Administer

First Thread:
[[I have a User DSN set up through the ODBC Data Source Administrator, which points to a default database on SQL server. All my tables in Access are linked to this database, and I use the same Access application whether I'm running against Dev or Stage or Prod, by simply changing the SERVER reference in my User DSN. My question is this... is there a way for Access to know which environment my ODBC connection is pointing to, and display the server name on reports?]]

Second Thread:
[[I have a User DSN set up through the ODBC Data Source Administrator, which points to a default database on SQL server. All my tables in Access are linked to this database, and I use the same Access application whether I'm running against Dev or Stage or Prod, by simply changing the SERVER reference in my User DSN. My question is this... is there a way for Access to know which environment my ODBC connection is pointing to, and display the server name on reports?]]
Apr 30 '14 #1
15 6248
jimatqsi
1,271 Expert 1GB
The DSN simply serves as a reference point when you link tables. The name of the DSN is not stored in the connection string; the server, database and other connection properties are stored. So, yes, you can pull the server name from each table's connection string.

You'll use something like
Expand|Select|Wrap|Line Numbers
  1. dim tbl as table
  2. set tbl = CurrentDB.Tabledefs(tablename)
  3. msgbox tbl.Connect ' show connect string
  4.  
Jim
Apr 30 '14 #2
Seth Schrock
2,965 Expert 2GB
Actually the DSN name is stored, but not the server name.

From looking around the Internet, there doesn't seem to be an easy way to read the DSN information. What you could do is create a DSN-less connection and just store the server name that you have chosen in a tempvar to be able to pull later and put in the report. DSN-Less Connection
May 1 '14 #3
zmbd
5,501 Expert Mod 4TB
adefries:
Please do not double post your question.

This is against the site policy.

Please keep in mind that moderators, experts, and others are un-paid volunteers that attempt to provide some help and guidance in-between our obligations to work and family.

Please be patient – especially on holidays and busy posting days.

In the future, both threads may simply be deleted.
May 1 '14 #4
jimatqsi
1,271 Expert 1GB
Seth, tell me about that. I'm using a Access 2007 front-end now, with ODBC connection to a SQL back-end. If I get the connection string I see ODBC;DriverSQL Server;SERVER=servername;UID= ...etc..."

Under what conditions do you get the DSN?

Jim
May 1 '14 #5
Seth Schrock
2,965 Expert 2GB
This is what I get in Access 2010 connecting to SQL server through DSN (string broken up for readability):
Expand|Select|Wrap|Line Numbers
  1. ?currentdb.TableDefs("emp_tblRoles").Connect
  2. ODBC;DSN=EmployeeDatabase;
  3.    Description=Employee Database;
  4.    Trusted_Connection=Yes;
  5.    APP=Microsoft Office 2010;
  6.    DATABASE=EmployeeDatabase;
  7.    Network=DBMSSOCN
This is also what I found everyone else online to report finding.

I did find a link for how to create the DSN through VBA (involves working directly with the registry), but I haven't had time to reverse engineer it to be able to pull the registry values.
May 1 '14 #6
I am finding the same thing as Seth. I do not see the server name on the connection string, only the DSN and database name. I don't know how, or if, it's possible for Access to 'see' the server that the DSN is currently pointed to.
May 1 '14 #7
jimatqsi
1,271 Expert 1GB
Do you get the same result if you are not using a Trusted Connection? I'm not able to test a Trusted Connection at the moment.

Jim
May 1 '14 #8
jimatqsi
1,271 Expert 1GB
It might be a function of network security policies. I can't think of any other reason for it.
May 1 '14 #9
zmbd
5,501 Expert Mod 4TB
If you have connected/linked tables try the following:
Start a new query
Do not add tables
Switch to SQL view
C&P
Expand|Select|Wrap|Line Numbers
  1. SELECT MSysObjects.Connect
  2.    , MSysObjects.Database
  3.    , MSysObjects.ForeignName
  4.    , MSysObjects.Name
  5. FROM MSysObjects
  6. WHERE (((MSysObjects.Type)=4 
  7.         Or (MSysObjects.Type)=6));
  8.  
In my case, SERVER=10.255.255.05 because that is how I set the DSN up... via IP address. 01 is our test, 05 is our production, 10 is our shadow server for 05. So, I split on ";" push the array for "server=" split that cell on "." look at the last cell of the array for the server.

My curiosity is why do you need the Server name?

You can of course do an API call to the ODBC DLL and parse the objects therein; however, I'm not that versed in the API calls.
May 1 '14 #10
jimatqsi
1,271 Expert 1GB
I use file DSNs when I set them up through the Administrator. I think the result is the same when I set them up through the Access ODBC wizard. I wonder if you see any difference using the wizard as opposed to the Windows Administrator.

Jim
May 1 '14 #11
Seth Schrock
2,965 Expert 2GB
I use System DSNs and that may be the difference.
May 2 '14 #12
I will try some of the things suggested.
May 2 '14 #13
If I create a new DSN from within Access, I see the server name on the connection string. Thanks for everyone's input.
May 2 '14 #14
Well I'm still working this problem.... When I created the DSN from within Access, it created a FILE DSN. The File DSN does show the server name in the connection string. However, the File DSN doesn't refresh the link if the server is subsequently changed. With the User DSN, as the Server is changed through the ODBC Data Source Administrator, it automatically points all the tables in Access to the new server. No so with a file DSN. This is all kind of new to me, so I'm confused. The User DSN works in every way, except I can't see the server name on the connection string. I need the reports in access to be able to dynamically refresh the server name whenever it's changed. It's a requirement that the reports indicate whether the data came from the DEV server, or the STAGE server or the Production Server. We're constantly switching between servers, so I don't think the File DSN will work for me. Someone recommended an API call to the ODBC DLL, but I am not familiar with API calls and don't know how to do that. Any more suggestions?
May 5 '14 #15
Seth Schrock
2,965 Expert 2GB
My recommendation would be to use a DSN-less connection. I have only used it once, but I think that in your case of having to change servers often, it would be best. The other option would be to create multiple User or System DSNs; one for each server. Put the server name in the description field. When you want to change servers, just change which DSN you are attached to. When you need to know which one you are attached to, then you can just get the description from the connection string. **NOTE** This is an untried idea.

If you go the DSN-less connection way, the server name is stored in the connection string. You could even create a table to store the information for each string and then have a combo box so that you can select which one to you want to connect to and then use the After_Update event to trigger the server change. The link on how to set this up is in post #4.
May 5 '14 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: SkunkDave | last post by:
Is there a script anyone has that will automate the addition of an access database to the OBDC datasources in control panel. Thanks
5
by: grondaia | last post by:
Here's my situation: I have an ODBC DSN setup for Timberline Data (An accounting package that uses pervasive.sql) on my sql box. I set up a linked server using the supplied timberline odbc...
0
by: Adrian Schlesinger | last post by:
Here is what happens (Windows 2000): 1. open the ODBC Data Source Administrator 2. go to the System DSN tab 3. then click Add - the Create Data Source screen pops up 4. select Microsoft Access...
6
by: Jozef | last post by:
Hello, Is there any way to automatically create an ODBC data source if it doesn't already exist? I'd like to deploy this program on workstations that I may not have access to, and don't want...
1
by: Chris | last post by:
Does anyone know how to programmatically launch the ODBC Data Source Administrator dialog? Thanks.
0
by: Dan Keeley | last post by:
Hi, I have setup an install project for my .net app, and I need to make it add an odbc data source when the software is installed. Unfortunately googling for this is a bit awkward.. Any ideas...
0
by: Phil Haddock | last post by:
Hi, I'm converting an existing Access application to vb.net 2003. The application allows users to select a number of tables from an ODBC data source, and nominate names for each table to use...
2
by: JeffN825 | last post by:
Hello, Thank you in advance for any assistance. I am trying to set up a mail merge from VB6/VBA code with Word 2000 using an ODBC data source (SQL 2000). I have successfully gotten the...
3
by: KEMoore | last post by:
I am trying to read data located on an ODBC box. I have multiple queries built in SQL2005. Now I just need to be able to access this data from the ODBC server in the SQL2005. I have tried to create...
1
by: steven_nospam at Yahoo! Canada | last post by:
I am a UNIX person (not much experience with MS Access) who during a recent upgrade on an IBM RS/6000 server had to convert our system due to an upgrade to a new software revision. The old...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.